Skip to content

Handle transient verify and retry states cleanly#25

Merged
jclusso merged 1 commit into
masterfrom
fix-transient-retry-handling
Jun 1, 2026
Merged

Handle transient verify and retry states cleanly#25
jclusso merged 1 commit into
masterfrom
fix-transient-retry-handling

Conversation

@jclusso
Copy link
Copy Markdown
Member

@jclusso 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
Copilot AI review requested due to automatic review settings June 1, 2026 17:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_again code, mapped to the retry-later exit bucket.
  • Reinterpret RateLimit-Reset as a Unix timestamp (drop Retry-After fallback) and align human/JSON renderers and backoff accordingly.
  • Plumb cmd.Context() through requireAuth, send spinner/progress to stderr, honor Quiet on API-key login, and reset root flag globals on each newRootCmd.

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.

@jclusso jclusso merged commit 4b3da97 into master Jun 1, 2026
4 checks passed
@jclusso jclusso deleted the fix-transient-retry-handling branch June 1, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants