Skip to content

fix(pr-triage): retry a GitHub API 5xx or network error before the step fails - #288

Merged
bketelsen merged 1 commit into
mainfrom
lucilla/night-core-pr-triage-retries-a-github-t168-muyilqg6ky7oqxh5
Nov 22, 2026
Merged

bketelsen merged 1 commit into
mainfrom
lucilla/night-core-pr-triage-retries-a-github-t168-muyilqg6ky7oqxh5

Conversation

@frostyard-machines

Copy link
Copy Markdown
Contributor

Summary

Closes #286.

createGitHubApi.request (scripts/lib/risk-paths.mjs) made 1 attempt per GitHub API call. A transient HTTP 500 failed the levels step and turned the pr-triage / pr-triage check red until a person re-ran it (frostyard/snowkit#21, run 42858589083 attempt 1: GitHub API GET /repos/frostyard/snowkit/pulls/16/files failed: HTTP 500; attempt 2 passed on the same SHA).

  • request retries an HTTP 5xx answer or a network error (fetch throws), at most API_MAX_ATTEMPTS = 3 attempts, with backoff API_RETRY_BASE_MS * 2^(n-1): 1 s, then 2 s. The worst case adds 3 s per call; the job keeps timeout-minutes: 5.
  • A 4xx is never retried: 403 (missing grant, secondary rate limit) still gives readiness unknown, and 404 with allow404 still returns null after 1 attempt.
  • Only requests that are safe to repeat retry: GET, DELETE, and the add-labels POST (retry: true; adding a label the issue has is a no-op). The comment POST makes 1 attempt, since a 5xx can still have written the comment (a re-run finds the readiness marker; the shadow step removes duplicates).
  • After the last attempt the error is the same as before: the same message and error.status.
  • createGitHubApi takes an optional sleep(ms) (default setTimeout), so the tests do not wait for real.
  • The embedded copy in .github/workflows/pr-triage.yml was rewritten only by npm run sync:risk-paths-workflow.
  • Specs: docs/specs/pr-triage.md (rule D) and docs/specs/risk-paths.md (job rules) state the retry contract.

Callers get the fix when they move their pin: #287.

Risk tier

Risk tier: 3 — risk:high. Matched paths in .github/risk-paths.json, and why the change is safe:

  • scripts/lib/risk-paths.mjs (L2, quality-gates): only createGitHubApi.request and addLabels change. The validator, matcher and levels are untouched. The retry adds no new request, URL, header or token use; it repeats the same request at most 2 more times, and only on a 5xx or a network error. Every 2xx and 4xx path behaves as before (tests below).
  • .github/workflows/** (L2, workflow-and-permissions): pr-triage.yml changes only inside the RISK_PATHS_EOF heredoc, regenerated by the sync script; no step, if:, permission or action pin changes. npm run check:risk-paths passes.

Verification

  • make ci at 8378246: 1079 tests, 1079 pass, 0 fail (check:docs, check:organization, check:scripts, check:corrections, check:risk-paths green).
  • New tests in test/risk-paths.test.mjs: 500 then 200 passes after 2 fetches with sleeps [1000]; a network error then 200 passes; 503 ×3 fails after exactly 3 fetches with sleeps [1000, 2000], the same message and status: 503; network error ×3 fails after 3; 400, 403, 404, 422 and 429 make 1 fetch and no sleep; getFileAtRef 404 gives null after 1 fetch; the comment POST on 500 makes 1 fetch; addLabels and removeIssueLabel retry; a non-function sleep is refused.
  • Existing client tests that reach a 5xx pass a no-op sleep; npm test time is unchanged (28.9 s before, 28.7 s after).
  • Revert test: with const attempts = 1; in request (no retry), node --test test/risk-paths.test.mjs fails 6 retry tests on their assertions (plus 4 workflow-copy drift tests, as expected for an unsynced edit):
✖ listPullFiles retries an HTTP 500 and passes on attempt 2
  Error: GitHub API GET /repos/o/r/pulls/5/files failed: HTTP 500
✖ listPullFiles retries a network error and passes on attempt 2
  Error: GitHub API GET /repos/o/r/pulls/5/files failed: fetch failed
✖ listPullFiles stops after 3 HTTP 503 attempts
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
  1 !== 3
✖ listPullFiles stops after 3 network errors
✖ addLabels retries HTTP 500 and passes on attempt 2
✖ removeIssueLabel retries HTTP 502 and passes on attempt 2
ℹ pass 135
ℹ fail 10

Restored: 145 pass, 0 fail.

  • Workflows changed: only the generated heredoc; actions, permissions and checkout settings unchanged.

Not tested: no live 5xx on GitHub; the retry is covered by unit tests with a fake fetch.

…ep fails

createGitHubApi.request made 1 attempt, so a transient HTTP 500 from
GitHub turned the pr-triage check red (frostyard/snowkit#21). GET, DELETE
and the add-labels POST now make at most 3 attempts on a 5xx or a network
error, with 1 s and 2 s backoff. A 4xx and the comment POST are never
retried. The embedded copy in pr-triage.yml comes from
npm run sync:risk-paths-workflow.

Closes #286
@github-actions github-actions Bot added level:L2 Read the diff risk:high Touches a path in .github/risk-paths.json labels Nov 22, 2026
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 22, 2026
@bketelsen
bketelsen added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit f99acfd Nov 22, 2026
5 checks passed
@bketelsen
bketelsen deleted the lucilla/night-core-pr-triage-retries-a-github-t168-muyilqg6ky7oqxh5 branch November 22, 2026 04:24
This was referenced Nov 22, 2026
bketelsen pushed a commit to frostyard/frostui that referenced this pull request Nov 22, 2026
Advance the reusable `pr-triage.yml` pin to `f99acfddee0a5466990b72e6292a5b1642444a25` for the [core#287 rollout](frostyard/core#287). [core#288](frostyard/core#288) adds bounded retries for GitHub API 5xx responses and network errors on reads, deletes and idempotent label adds. It never retries the comment POST.

**Risk path:** `.github/workflows/risk-paths.yml` matches `.github/workflows/**` (L2). Only the full SHA and its comment change. The caller's trigger and permissions are unchanged; the pinned workflow still runs no PR code and reads the risk list at the PR's base SHA. Canary runs in [clix#136](frostyard/clix#136) and [std#122](frostyard/std#122) validated the exact pin after merge. See the [canary run evidence](frostyard/core#287 (comment)) and the [upstream workflow diff review](frostyard/clix#136 (comment)).

`make ci BASE=origin/main` passed locally before push. The existing pin checks validate the SHA format, not the specific SHA. Revert test: exempt (reusable workflow pin only; no local implementation or test changes). This PR's own `pull_request_target` runs use the base branch pin, not the new one.
bketelsen pushed a commit to frostyard/lodge that referenced this pull request Nov 22, 2026
…errors) (#114)

Moves the PR triage caller from core 981e7ae to f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried, never the comment POST. Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/porter that referenced this pull request Nov 22, 2026
…errors) (#55)

Moves the PR triage caller from core 981e7ae to f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried, never the comment POST. Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/apt-publisher that referenced this pull request Nov 22, 2026
…errors) (#69)

Moves the PR triage caller to the merge of frostyard/core#288, the first core main commit with the retry of a GitHub API 5xx or network error (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/igloo that referenced this pull request Nov 22, 2026
…errors) (#30)

Moves the PR triage caller to frostyard/core f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/nsl that referenced this pull request Nov 22, 2026
…errors) (#125)

Moves the PR triage caller to frostyard/core f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/pilothouse that referenced this pull request Nov 22, 2026
…errors) (#285)

Moves the PR triage caller to frostyard/core f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/snowkit that referenced this pull request Nov 22, 2026
…errors) (#24)

Moves the PR triage caller to frostyard/core f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/chairlift that referenced this pull request Nov 22, 2026
…errors) (#330)

Moves the PR triage caller to frostyard/core f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/frostmail that referenced this pull request Nov 22, 2026
…errors) (#369)

Moves the PR triage caller from core 981e7ae to f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried, never the comment POST. Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/frostnotes that referenced this pull request Nov 22, 2026
…errors) (#258)

Moves the PR triage caller from core 981e7ae to f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried, never the comment POST. Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/homebrew-tap that referenced this pull request Nov 22, 2026
…errors) (#58)

Moves the PR triage caller to the merge of frostyard/core#288, the first core main commit with the retry of a GitHub API 5xx or network error (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/bootc-debian that referenced this pull request Nov 22, 2026
…errors) (#35)

Moves the PR triage caller to the merge of frostyard/core#288, the first core main commit with the retry of a GitHub API 5xx or network error (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/flatpak-index that referenced this pull request Nov 22, 2026
…errors) (#25)

Moves the PR triage caller to the merge of frostyard/core#288, the first core main commit with the retry of a GitHub API 5xx or network error (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/omarchy-apps that referenced this pull request Nov 22, 2026
…errors) (#29)

Moves the PR triage caller to the merge of frostyard/core#288, the first core main commit with the retry of a GitHub API 5xx or network error (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
bketelsen pushed a commit to frostyard/intuneme that referenced this pull request Nov 22, 2026
…errors) (#306)

Moves the PR triage caller to frostyard/core f99acfd, the merge of frostyard/core#288: a GitHub API 5xx or network error is retried (frostyard/core#286). Rollout: frostyard/core#287.

Co-authored-by: frostyard-machines <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L2 Read the diff ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pr-triage: retry a GitHub API 5xx or network error before the step fails

2 participants