Retry sidecar API 429s honouring Retry-After (30s budget)#417
Merged
Conversation
Adds RetryOn429Budget to httpcl.Config. When set, the client retries HTTP 429 responses honouring the Retry-After header (integer seconds or HTTP date). Retries stop and a RateLimitError is returned when the cumulative elapsed+wait time would exceed the budget, or when a single Retry-After value exceeds it. Non-429 retry behaviour (5xx, network errors) is unchanged — a per-call counter caps those at the original 3-retry limit even though RetryMax is raised to 30 for 429 headroom. Also fixes a resp.Body leak when retryablehttp returns both a response and a CheckRetry error. The CircleCI API client uses a 30s budget, covering all sidecar calls. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
schurchleycci
approved these changes
Jun 25, 2026
- Derive RetryMax from budget (budget/s + origMax) instead of hardcoding 30; prevents premature cap on budgets > ~30s - Merge duplicate if-retryOn429Budget blocks in Call() - Add TestRetryOn429_5xxStillCapsAtThreeWithBudgetSet: verifies non-429 retry cap is preserved when budget is configured - Add client_internal_test.go covering all parseRetryAfter branches including HTTP-date format, past date, missing header, invalid value 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.
Summary
RetryOn429Budgettohttpcl.Config: retries HTTP 429 responses by honouring theRetry-Afterresponse header (integer seconds or HTTP date)RateLimitErroris returned when elapsed + pending wait would exceed the budget, or when a singleRetry-Aftervalue exceeds it — error message is agent-readable: "rate limited: server requests 45s back-off, retry budget of 30s exhausted — try again later"RetryMaxis raised to 30 for 429 headroomresp.Bodyleak whenretryablehttpreturns both a response and aCheckRetryerrorIsRateLimitErrorhelper added for callers that need to distinguish rate-limit failures