fix: throw HttpError for non-retryable HTTP failures in updateRef#1158
Open
qozle wants to merge 2 commits intoanthropics:mainfrom
Open
fix: throw HttpError for non-retryable HTTP failures in updateRef#1158qozle wants to merge 2 commits intoanthropics:mainfrom
qozle wants to merge 2 commits intoanthropics:mainfrom
Conversation
…terface retryWithBackoff retried all errors unconditionally, including deterministic failures like WorkflowValidationSkipError (401 workflow-not-on-default-branch), wasting ~35 seconds per occurrence. Introduces a NonRetryable marker interface in src/utils/errors.ts. Any error class that sets `retryable = false as const` is automatically skipped by retryWithBackoff without requiring callers to pass a custom shouldRetry option. The shouldRetry option is also added to RetryOptions for explicit control. WorkflowValidationSkipError now implements NonRetryable, fixing the primary reported case. The shouldRetry check is guarded inside `attempt < maxAttempts` to prevent spurious "aborting retries" log messages on the final attempt. Also fixes a gap in prepare.ts: WorkflowValidationSkipError was not caught there, causing the action to fail instead of skip (run.ts already handled this correctly). Updates misleading comments in github-file-ops-server.ts that claimed non-403 errors would not be retried — they were. See anthropics#1156 for the follow-up fix. Closes anthropics#1081
The two updateRef call sites in github-file-ops-server.ts threw plain Error for all non-2xx responses, causing retryWithBackoff to retry deterministic failures (400, 404, 409, 422) that will never succeed. Adds HttpError to src/utils/errors.ts. It implements NonRetryable (retryable = false as const), so retryWithBackoff automatically skips retries without needing an explicit shouldRetry option at the call sites. 403 errors intentionally keep throwing plain Error — they are documented as intermittent transient GitHub API issues that succeed on retry. Closes anthropics#1156
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.
Summary
Fixes #1156. Two
updateRefcall sites ingithub-file-ops-server.tsthrew plainErrorfor all non-2xx HTTP responses, soretryWithBackoffretried deterministic failures like 404 (branch not found), 422 (validation failed), and 409 (conflict) — wasting up to 10 seconds per failure.What changed
Adds
HttpErrortosrc/utils/errors.ts:Both
updateRefcall sites now throwHttpErrorfor non-403 non-2xx responses. SinceHttpErrorimplementsNonRetryable,retryWithBackoffskips retries automatically — noshouldRetryoption needed at the call sites.403 intentionally keeps throwing plain
Error— the existing comment documents these as intermittent transient GitHub API issues that succeed on retry.Dependency
This PR builds on #1157 (which introduces
NonRetryableand updatesretryWithBackoff). It should be merged after #1157. The diff on top ofmainonce #1157 lands is exactly this commit.Tests
4 new tests in
test/retry.test.ts:HttpErrorhasretryable=falseandisNonRetryablereturns trueHttpErrorexposesstatusandnameHttpErroris not retried byretryWithBackoffError(simulating 403) IS still retriedAll 674 tests pass.