`GitlabRepo#issue` and `close_issue` rescue only `NotFound`; `Unauthorized`/`Forbidden`/`TooManyRequests` propagate unhandled, plus typo `"can' comment"`
#853 opened on May 11, 2026
Repository metrics
- Stars
- (142 stars)
- PR merge metrics
- (PR metrics pending)
Description
What happens
In objects/vcs/gitlab.rb, the GitLab VCS adapter rescues only Gitlab::Error::NotFound:
def issue(issue_id)
...
rescue Gitlab::Error::NotFound => e
raise "The issue most probably is not found, can' comment: #{e.message}"
end
def close_issue(issue_id)
@client.close_issue(@repo.name, issue_id)
rescue Gitlab::Error::NotFound => e
raise "The issue most probably is not found, can't close: #{e.message}"
end
def add_comment(issue_id, comment)
@client.create_issue_note(@repo.name, issue_id, comment)
rescue Gitlab::Error::NotFound => e
raise "The issue most probably is not found, can't comment: #{e.message}"
end
Three issues here.
-
Gitlab::Error::Unauthorized,Gitlab::Error::Forbidden,Gitlab::Error::TooManyRequests, andNet::OpenTimeout/Errno::ECONNREFUSED(network failures) are not caught. A revoked GitLab token, a rate limit, or a transient network error therefore crashes the call with the raw upstream exception class, defeating the wrapper's purpose of producing a stable error contract. -
The wrapper is also inconsistent with the same file's
exists?method (lines 120-133), which does rescue bothGitlab::Error::NotFoundandGitlab::Error::Forbidden. So the policy is "narrow rescue here, wider rescue there" within one class. -
There is a typo on line 38:
"The issue most probably is not found, can' comment"— a missing letter (and a missing apostrophe pairing) compared to"can't close"and"can't comment"elsewhere in the same file.
This is the same defect family as the recently-accepted zerocracy/judges-action#1357–#1362 (too-narrow Octokit rescues) and as the GithubRepo neighbour of this same gitlab.rb (already tracked there via @todo #312).
What should happen
Widen each rescue to the full family of Gitlab::Error plus common network errors, matching the wider rescue convention already used by exists?:
rescue Gitlab::Error::NotFound,
Gitlab::Error::Unauthorized,
Gitlab::Error::Forbidden,
Gitlab::Error::TooManyRequests => e
raise "Can't reach GitLab issue #{issue_id}: #{e.message}"
end
And fix the typo "can' comment" → "can't comment" on line 38.
Result: revoked tokens, rate limits, and missing issues all surface as the same wrapper exception type the rest of 0pdd already handles, the wrapper's stable-error contract is honoured, and the typo no longer appears in operator-facing logs.