Repository navigation
feat(CLI): retry requests on 429 concurrency and rate limit responses #STRINGS-4937 - #1379
Conversation
…#STRINGS-4937 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
API changelog (oasdiff)Doc-only edits (descriptions, examples) do not appear here. |
There was a problem hiding this comment.
🟡 Changes recommended
The retry backoff sleep ignores request cancellation and deadlines, potentially blocking callers for minutes before retrying.
1 open issue
What changed in this PR
This PR adds HTTP 429 retries to the CLI’s shared API client to help phrase push and phrase pull recover from concurrency and rate limits.
Changes:
- Adds a transport wrapper with up to 20 retries, reason-based delays, and request-body replay.
- Enables the wrapper in
newClient(). - Adds tests for retry delays, past reset times, retry exhaustion, and body replay.
| File | Description |
|---|---|
clients/cli/cmd/internal/retry_transport.go |
Implements retry handling and backoff calculation. |
clients/cli/cmd/internal/retry_transport_test.go |
Tests retry behavior, delays, and body replay. |
clients/cli/cmd/internal/pull.go |
Configures the shared API client to use the retry transport. |
Review effort: Balanced
…NGS-4937 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks for unifying this, and having the transport cover push, polling and the other API calls is a good improvement. I read the diff and checked the generated Go client template. Request replay is safe, because bodies are A few things I'd suggest changing or discussing:
On the description's open items: the |
|
another suggestion: should be easy to add a simple spec in |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks for the thorough review, jablan. Pushed
Spec: I added it to Open: I haven't checked the 🤖 Addressed by Claude Code |

Ticket: https://phrase.atlassian.net/browse/STRINGS-4937
What
phrase push/phrase pullnow retry requests the API rejects with HTTP 429, via aRoundTripperwrapper set on the API client innewClient()(clients/cli/cmd/internal/retry.go).X-Rate-Limit-Reason: global-concurrency(or a 429 without a usableX-Rate-Limit-Reset): exponential backoff from 250 ms up to 5 s, plus up to 50% jitter so parallel workers don't retry in lockstep.global-rate(or any other 429 with a validX-Rate-Limit-Reset): print a warning, wait until the reset (+1 s), then retry.GetBody, so multipart uploads are sent intact. The backoff wait stops when the request context is cancelled.Unified retry logic in
pullThe existing rate-limit handling in
pull.gois replaced by the transport, andretryTransient(body/transport errors) now lives inretry.gowith the same sleep hook.downloadWithRateGate(theRWMutexgate),waitForRateLimitand theRate.Remaining == 0retry blocks.Verification
retry_test.go,pull_retry_test.go) cover both reasons, reset in the past, giving up, body replay, cancellation during backoff, and transport-error retries.X-Rate-Limit-Resetformat is assumed to be a unix timestamp (inferred, not confirmed against the live API).X-Rate-Limit-Limit/Remainingare not read. Not run against the real API.go test ./cmd/...reports a build failure in thecmdpackage's generatedapi_*.gofiles, which don't match phrase-go v4.38.0. This comes from files not touched by this PR.🤖 Generated with Claude Code