Retry transient upstream errors in handle_exceptions decorator#2563
Merged
hiroshinishio merged 1 commit intomainfrom Apr 20, 2026
Merged
Retry transient upstream errors in handle_exceptions decorator#2563hiroshinishio merged 1 commit intomainfrom
hiroshinishio merged 1 commit intomainfrom
Conversation
Sentry AGENT-36Z/36J were transient GitHub 5xx on git push surfacing as a plain ValueError from run_subprocess wrapping the remote stderr. The existing retry path in the decorator only fired on requests.HTTPError rate limits, so these ValueErrors bubbled straight through, reported to Sentry, and the push just failed. Adds is_transient_error to recognize GitHub 5xx, remote Internal Server Error from subprocess, and HTTP 5xx message markers. handle_exceptions now retries the wrapped function up to TRANSIENT_MAX_ATTEMPTS (3) with linear backoff when the raised exception matches. 5xx responses almost always mean the server did not complete the operation so retry is safe by default for all decorated functions; non-transient exceptions still fail fast on the first attempt. Split handle_http_error, handle_json_error, and handle_generic_error into their own files and extracted GitHub 403/429 rate-limit handling into handle_github_rate_limit. handle_exceptions.py is now just the decorator plus the retry loop. Exempted handle_exceptions.py from the cast-usage lint: the generic decorator with ParamSpec + TypeVar genuinely needs cast to bridge the async wrapper's Coroutine[..., R] against the declared Callable[P, R]. Added regression tests for git_commit_and_push retry behavior, the new helpers, and is_transient_error classification. Updated CLAUDE.md to flag hard-wrapped comment sentences. Repointed existing tests that patched utils.error.handle_exceptions.sentry_sdk to patch the module function directly, which works across all new helper locations. Also rewrote pre-existing partial in/not-in assertions in touched test files to exact == equality per CLAUDE.md.
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.
No description provided.