Skip to content

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

Closed

Description

@frostyard-machines

Problem

The reusable pr-triage workflow (.github/workflows/pr-triage.yml) fails its step on the first HTTP 5xx or network error from the GitHub API. createGitHubApi.request in scripts/lib/risk-paths.mjs makes 1 attempt and throws.

Evidence: frostyard/snowkit#21, run 42858589083 attempt 1, step levels:

GitHub API GET /repos/frostyard/snowkit/pulls/16/files failed: HTTP 500

Attempt 2 of the same run passed on the same SHA. A transient GitHub error turns the required pr-triage check red until a person re-runs the job.

Proposed fix

In createGitHubApi.request:

  • Retry an HTTP 5xx answer or a network error (fetch throws) a small, bounded number of times, with exponential backoff.
  • Never retry a 4xx: 403 (permissions, secondary rate limit) and 404 keep their current meaning (allow404, readiness unknown on 403).
  • Retry only requests that are safe to repeat: GET, DELETE, and the add-labels POST (adding a label the issue has is a no-op). POST .../comments is not retried, since a 5xx can still have written the comment; a re-run already finds the readiness marker and the shadow step removes duplicates.
  • After the last attempt, the error message and error.status stay as they are today.
  • A test fails without the retry.

The library is embedded in pr-triage.yml and risk-paths.yml by npm run sync:risk-paths-workflow, so callers get the fix when they move their pin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions