Skip to content

fix(github): removePullRequestLabel swallows every error, not just the documented 404 #6192

Description

@JSONbored

Context

src/github/labels.ts:72-87's doc comment says removing a label is "Best-effort — a 404 (label not on the PR) is ignored." But the implementation is a bare .catch(() => undefined) with no status check at all — a 500, 403, or rate-limit failure is discarded identically to a 404, silently and unlogged. The same file's ensurePullRequestLabel (label-creation) catch a few lines above explicitly narrows what it swallows (e.status !== 422 || !e.message?.includes("already_exists") then re-throw), making removePullRequestLabel the inconsistent outlier within its own file.

Requirements

  • Change removePullRequestLabel's catch to check the error status, following ensurePullRequestLabel's exact narrowing pattern in the same file: only swallow a 404 (label not present, the documented best-effort case); re-throw (or at minimum log via this codebase's existing error-capture convention) anything else.
  • Do not change ensurePullRequestLabel — it's already correct and is the reference pattern.

Test Coverage Requirements

99%+ Codecov patch coverage on both the swallowed-404 branch and the re-thrown/logged non-404 branch; add regression tests for both cases.

Deliverables

  • removePullRequestLabel only silently swallows a real 404; any other failure is surfaced (thrown or logged), matching ensurePullRequestLabel's convention.
  • Regression tests for both the 404 and non-404 cases.

Expected Outcome

A genuine GitHub API failure (rate-limit, permission error, 500) while removing a label is no longer silently discarded and unlogged.

Links & Resources

  • src/github/labels.ts:72-87 (the bug), same file's ensurePullRequestLabel (the correct reference pattern a few lines above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions