Repository navigation
Retry rate-limited API requests, and stop when an API token's organization can't be looked up - #2407
Merged
Merged
Conversation
…ation can't be looked up Co-Authored-By: Claude <noreply@anthropic.com>
Coverage Report for CI Build 39617783146Coverage increased (+0.03%) to 45.355%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
jeremybeard
marked this pull request as ready for review
October 21, 2026 14:42
schnie
approved these changes
Oct 21, 2026
schnie
added a commit
that referenced
this pull request
Oct 22, 2026
Retries: a Retry-After wait is capped at 10s rather than taken as given; the retry check no longer returns an error beside a response, which left the response unclosed; and the retrying client closes only its own idle connections, not http.DefaultTransport's, which every client shares. Organization lookup: checkAPIToken and checkAPIKeys share one lookup, so an empty list or an organization with no product is ErrAPITokenOrganization rather than a panic, and API keys stop on a failed lookup as an API token does. The product cannot be skipped: an environment login keeps it only for the process, and it is what tells a hosted organization from a hybrid one. astro auth token still skips a lookup that failed for want of the API, but not one the API refused with 401 or 403: that token no longer works. astro api registry, which is public, needs no login at all. Co-Authored-By: Claude <noreply@anthropic.com>
schnie
added a commit
that referenced
this pull request
Oct 22, 2026
Merge main into v2, and port #2407
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.
Description
When the API token's organization lookup fails, the command now stops with that error, and the v1 and v1alpha1 clients retry 429s up to three times with a jittered 1–2s backoff.
An e2e job in astronomer/deploy-action ran several jobs on one token at once and hit the API's per-token rate limit.
ListOrganizationsgot a 429 from the gateway, so the context was never given an organization. The pre-run hook only logs setup errors, soastro workspace switchwent on to request/v1/organizations//workspacesand failed withInvalid URL: organizationId cannot be empty.Only 429s are retried, since the gateway refuses those before the API sees them, so a write is never sent twice. All other setup errors are still only logged, so a value in
ASTRO_API_TOKENthat isn't an API token still falls back to the existing login (#2217).🎟 Issue(s)
🧪 Functional Testing
Unit tests cover the retry against an
httptestserver: the body is resent, the final 429 is returned once retries run out, other statuses aren't retried, and a cancelled request stops waiting. They also cover the hook stopping the command on a failed organization lookup and still only logging the other setup errors.📸 Screenshots
📋 Checklist
make testbefore taking out of draftmake lintbefore taking out of draft