Skip to content

Retry PR review watch while GitHub indexes the dispatched run - #8045

Open
HsingTang wants to merge 1 commit into
mainfrom
HsingTang/fix-cli-review-watch-indexing
Open

HsingTang wants to merge 1 commit into
mainfrom
HsingTang/fix-cli-review-watch-indexing

Conversation

@HsingTang

Copy link
Copy Markdown
Contributor

Changes

Retry the same dispatched review run when gh run watch reports a run-lookup HTTP 404. Keep twelve attempts, at most sixty seconds of retry delays, and the existing twenty-minute job timeout. Backend failures and other errors still fail the wrapper.

Why

GitHub can return 404 from watch immediately after view succeeds for a newly dispatched run. The wrapper currently exits even if the backend review later succeeds. This fix takes effect for future review requests after it merges to main.

Tests

  • Execute the real workflow shell with an external fake gh: transient and persistent 404s, same-run identity and single dispatch, backend failure/cancellation/timeout, and non-404 error propagation. All 20 authorization and wait tests pass; the new transient-404 regression fails on unchanged main.
  • Pinned Ruff lint/format, yamlfmt validation, Bash syntax, and changed-file whitespace checks pass. Repository-wide whitespace validation reports three unchanged PNG fixtures as UTF-8 decoding failures.
  • Local Isaac review completed with no final comments; minor observations were fixed or dispositioned against this bounded scope. No live backend review was dispatched for testing.

This PR was written by Codex.

@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: b034dad

Run: 45746569893

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 279 19 4:37
💚​ aws-windows-latest-4core-16gb 1 281 17 3:58
💚​ azure linux-2core-8gb 1 278 19 4:08
💚​ azure-windows-latest-4core-16gb 1 280 17 4:10
💚​ gcp linux-2core-8gb 1 279 19 4:05
💚​ gcp-windows-latest-4core-16gb 1 281 17 4:11
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
4:08 gcp-windows-latest-4core-16gb TestAccept
4:08 azure-windows-latest-4core-16gb TestAccept
3:52 aws-windows-latest-4core-16gb TestAccept

@HsingTang
HsingTang marked this pull request as ready for review November 26, 2026 03:25
@HsingTang
HsingTang requested a review from a team as a code owner November 26, 2026 03:25

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at b034dad. Each finding was verified against the code.

No blocking issues found. 3 non-blocking comment(s) and 1 question(s) below.

This PR drops the gh run view probe and retries gh run watch itself, up to 12 times 5s apart, when gh reports a run-fetch HTTP 404. It adds subprocess tests that run the real workflow shell against a fake gh. The retry logic does what the description says. I found only small issues: a leftover comment, a wasted final sleep and a stale branch in the fake gh. One open question is whether to retry only on gh's 404 text or on any first-lookup failure, as the old probe did.

Questions

  1. The retry now runs only when gh's stderr starts with failed to get run: HTTP 404:. That ties it to gh's error wording, and a transient 5xx on the first lookup now fails the wrapper. At base, any non-zero exit from the gh run view probe was retried. Is matching the exact 404 text intended, or would you rather keep a lookup probe that retries any failure (for example, view plus a short delay before watch), or also match HTTP 5[0-9][0-9]:? (non-blocking)

Comments outside the changed lines

  • [nit] .github/scripts/test_cli_pr_review.py:46: The workflow no longer calls gh run view, but the fake gh still answers it with a databaseId. That makes it look as if the probe is still exercised. Could you drop this branch so a stray view call falls through to exit 99, or assert that view is never called?

echo 'To request another review, comment `/review` on the PR.' >> "$GITHUB_STEP_SUMMARY"
# A newly dispatched run can briefly return 404 before GitHub indexes it.
# A newly dispatched run can briefly return 404 before GitHub indexes it,
# even after a successful view. Retry watch with at most one minute of delays.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] "even after a successful view" refers to the gh run view probe this hunk removes. A reader now sees no view before watch. Could this say something like "gh run watch can return 404 for a newly dispatched run before GitHub indexes it; retry the same run up to 12 times, 5s apart"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That phrase records the observed failure that motivated removing the separate probe: view succeeded, then watch immediately returned the run-fetch 404. It is historical rationale for retrying watch directly; it does not describe an additional call in the new loop. I have kept that context with the indexing-race comment.

if ! grep -q '^failed to get run: HTTP 404:' "$RUNNER_TEMP/review-watch.err"; then
exit "$status"
fi
sleep 5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] After the 12th 404 the loop still runs sleep 5 before it prints the error on line 114, so a persistent 404 waits 5s for nothing. test_persistent_not_found_is_bounded locks this in with ["5"] * 12. Should the loop skip the sleep when attempt is 12, or is that not worth it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keeps the existing twelve-attempt, sixty-second retry-delay policy unchanged, including the final delay. Skipping the last sleep would be a reasonable small cleanup, but is unnecessary to repair this race. The persistent-404 regression deliberately verifies that existing bound; the twenty-minute job timeout still bounds total time including watch.

@HsingTang

Copy link
Copy Markdown
Contributor Author

Yes, limiting retries to the run-fetch 404 is intentional. This repair targets the observed indexing race and retries the exact dispatched run. Auth/permission failures, backend failures and other errors (including 5xx) propagate. The old probe retried any failure, but retaining that behavior would also delay unrelated failures; the new regression cases check the narrower contract.

The fake view response is retained intentionally: it lets the same subprocess regression run against the original workflow, where view succeeds and the subsequent watch returns 404. That baseline check reproduces the original failure. The current workflow uses only watch, and every test checks the single dispatch and exact watched run ID.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants