Skip to content

Bot Auto-Approve fails on a transient 404 and leaves the PR silently unapproved #12

Open

Description

@principalwater

Symptom

Bot Auto-Approve failed on #10 with a bare gh: Not Found (HTTP 404), leaving the PR at REVIEW_REQUIRED with green CI and no indication of why. The same workflow succeeded for #9 minutes earlier and again for #11 afterwards, so this is intermittent rather than a misconfiguration.

Failed run — the Resolve PR context step, 10s in.

Recovering took a branch update to re-trigger CI so the bot would run again. That is a workable fallback, but it is not obvious from the failure, and the job sits in the approval path for every PR.

Cause

Resolve PR context runs under bash -e and makes three unguarded API calls in sequence:

PR_JSON=$(gh pr view "$PR_NUMBER" ... )
BASE_SHA=$(gh api repos/${{ github.repository }}/git/ref/heads/main --jq '.object.sha')
COMPARE_JSON=$(gh api repos/${{ github.repository }}/compare/${BASE_SHA}...${PR_HEAD_SHA} --jq '.')

Any of them returning 404 aborts the step. The log does not say which one, because none of them is labelled and the error is gh's own.

A 404 here is expected transient behaviour, not a bug in the caller: workflow_run fires as soon as CI completes, and the compare endpoint in particular can 404 briefly while GitHub catches up with a just-pushed head — which is exactly the window this job runs in.

Suggested fix

  1. Label each call so the failure names the endpoint that 404'd.
  2. Retry the compare call a few times before giving up; a couple of seconds is enough for the transient case.
  3. Decide deliberately what a persistent 404 means. Skipping with a clear message is probably right — the PR then waits for a human, which is the safe outcome for an approval gate — but failing loudly is also defensible. Failing silently from the PR's point of view is the part worth fixing.

Not urgent

Nothing is broken that a re-run does not fix, and it did not block the 0.5.11 release. Filing it because the job is in the approval path for every PR, so it will keep costing a re-run every time it trips.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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