fix: retry transient GitHub API failures and never fail on comment posting - #68
Merged
Conversation
…sting github_api retries 5xx and throttled 403/429 responses with bounded exponential backoff and jitter, honouring Retry-After and x-ratelimit-reset when GitHub sends them. Deterministic 4xx responses raise immediately. Posting a section into the PR comment is a cosmetic summary of work that already succeeded, so an unreachable API leaves a warning and exits 0 instead of failing the calling check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A transient GitHub API 5xx raised out of
github_api()and failed the whole job. On a PR where ruff, the health check, the license scan, pip-audit and the build all passed, five checks went red — the failing step in each was only "PostTwo changes, both in
scripts/update_pr_comment.py:github_api()retries transient failures (500/502/503/504, and 403/429 when GitHub signals throttling viaRetry-After,x-ratelimit-reset, or a rate-limit message) with bounded exponential backoff plus jitter, capped at 30s over 5 attempts. Deterministic 4xx such as 404/422 raise on the first response.main()catchesURLError(which coversHTTPError), logs a warning and exits 0. This subsumes the existing fork read-only-token case, and every consuming workflow benefits without needing its owncontinue-on-error.Regression tests cover the 503-then-200 retry, retry exhaustion, no-retry on 404/422 and on a plain non-throttled 403,
Retry-Afterbeing honoured, bounded backoff, and comment-post failure exiting 0. Sleep is patched throughout.🤖 Generated with Claude Code