Handle transient verify and retry states cleanly#25
Merged
Conversation
Member
jclusso
commented
Jun 1, 2026
- treat HTTP 249 as a retryable pending state with try_again code
- map try_again to the retry-later exit bucket
- align rate-limit backoff with documented RateLimit-Reset timestamp
- route auth refresh/progress through command context and stderr
- fix quiet API-key login output and reset root flag state between runs
- add regression coverage for retry, pending, quiet, and command-state behavior
- treat HTTP 249 as a retryable pending state with try_again code - map try_again to the retry-later exit bucket - align rate-limit backoff with documented RateLimit-Reset timestamp - route auth refresh/progress through command context and stderr - fix quiet API-key login output and reset root flag state between runs - add regression coverage for retry, pending, quiet, and command-state behavior
There was a problem hiding this comment.
Pull request overview
Cleans up handling of transient API responses (HTTP 249, 429) and a few command-context plumbing issues. Adds try_again as a new error code mapped to exit code 3, switches the rate-limit backoff to use the RateLimit-Reset Unix timestamp, threads cmd.Context() through requireAuth, routes spinner/progress output to stderr, fixes quiet-mode for API-key login, and resets root flag globals between runs. Documentation and tests are updated to match.
Changes:
- Treat HTTP 249 as a retryable pending state with new
try_againcode, mapped to the retry-later exit bucket. - Reinterpret
RateLimit-Resetas a Unix timestamp (dropRetry-Afterfallback) and align human/JSON renderers and backoff accordingly. - Plumb
cmd.Context()throughrequireAuth, send spinner/progress to stderr, honorQuieton API-key login, and reset root flag globals on eachnewRootCmd.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents 249/try_again, transient retry, and Reset-as-timestamp semantics. |
| internal/api/errors.go | Updates RateLimit.Reset doc to Unix timestamp. |
| internal/api/client.go | Adds isRetryableStatus (249/429), reworks backoffFor to use Reset timestamp + exponential fallback, drops Retry-After. |
| internal/api/client_test.go | Adds tests for 249 error, backoff timestamp behavior, and option forwarding. |
| cmd/errors.go | Adds try_again code, 249 "Pending:" rendering, and timestamp-based 429 retry hint. |
| cmd/errors_test.go | Tests new 249 rendering, JSON code, and exit-code mapping. |
| cmd/context.go | requireAuth now takes a context.Context for refresh. |
| cmd/context_test.go | Updates callers to pass context. |
| cmd/account.go, cmd/batch.go, cmd/verify.go | Pass cmd.Context() to requireAuth; route progress/spinner to stderr. |
| cmd/batch_e2e_test.go | Comment touch-up. |
| cmd/login.go | Honors ctx.Quiet for API-key login output. |
| cmd/login_e2e_test.go | Adds quiet-mode regression test. |
| cmd/root.go | Adds resetRootFlagState() invoked from newRootCmd. |
| cmd/root_test.go | Verifies flag globals are reset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.