Skip to content

Merge main into v2, and port #2407 - #2416

Merged
schnie merged 4 commits into
v2from
sync/main-into-v2-2026-10-21c
Oct 22, 2026
Merged

schnie merged 4 commits into
v2from
sync/main-into-v2-2026-10-21c

Conversation

@schnie

@schnie schnie commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Syncs main's one commit since #2415 into v2, and ports it.

Merge with "Create a merge commit", not squash. Squash drops main as a parent (see #2374 and the five record PRs before it).

PR How v2 files
#2407 Retry rate-limited API requests, and stop when an API token's organization can't be looked up Merged as a parent only, then ported every file it touches moved on v2, so the merge commit keeps v2's tree unchanged and the second commit carries the change

The port

Same change as main's, on v2's paths:

main v2
pkg/httputil/retry.go, retry_test.go same paths, as is
astro-client-v1/client.go internal/platform/astro/clients/astrov1/client.go, both NewV1Client and NewV1ClientForLogin (v2 only)
astro-client-v1alpha1/client.go internal/platform/astro/clients/astrov1alpha1/client.go
cmd/cloud/setup.go, setup_test.go cmd/astro/setup.go, setup_test.go
cmd/root_hooks.go, root_hooks_test.go (cloudSetup) same paths (astroSetup)

go-retryablehttp is now a direct dependency at v0.7.8, main's version (it was already in v2's graph at v0.7.7).

Test-only fixes for v2's stricter lint: import grouping in two test files, and a reason on retry_test.go's //nolint:bodyclose.

Review fixes (v2 only; main keeps #2407 as merged)

A /code-review of the port found these. Most apply to main as well; they are fixed here because 1.x is winding down.

Retries (pkg/httputil/retry.go)

  • A Retry-After wait is capped at 10s per retry. Before, it was taken as given, so Retry-After: 300 would hang a command about 15 minutes with no output.
  • The retry check no longer returns an error alongside a response. That made net/http drop the response unclosed when a context ended just after the reply. retryablehttp already stops waiting when the context ends.
  • The retrying client closes only its own idle connections. Wrapping the shared client directly meant every failed request closed http.DefaultTransport's connections, which Houston, Airflow and the version check also use. The new transport still reads the wrapped client's transport per request, so test transports and the no-network guard keep working.

The organization lookup (cmd/astro/setup.go)

  • checkAPIToken and checkAPIKeys share one lookup, environmentOrganization. An empty org list or an org with no product is now ErrAPITokenOrganization instead of a panic. API keys now stop on a failed lookup the way an API token does, and an empty deployments list is an error too.
  • Why the lookup can't be skipped: the review suggested taking the org from the token's claims and treating the lookup as optional. The product can't be dropped, though. An environment login keeps it only for the process, so every run must look it up, and it's what organization.IsOrgHosted() reads (deployment create/update validation, the monitoring DAG on deploy). Carrying on without it would treat a hosted org as hybrid.

Commands that don't need the org

  • astro auth token still skips a lookup that failed because the API was unavailable (a 429, a 503, a network error), since the token is saved first and printing it needs no org. It no longer skips one the API refused with 401 or 403: that token doesn't work, and printing it with exit 0 would hide that. TestPreRunLeavesJSONStdoutAlone now has both cases.
  • astro api registry queries the public provider registry, so it carries NoLoginAnnotation (as telemetry, config and context do) and the login check skips it.

Checks

  • git rev-list HEAD..origin/main is 0.
  • The merge commit's tree is identical to v2's.
  • After the review fixes: make test, make tidy-check and make deadcode pass locally; golangci-lint v2.13.2 reports 0 issues; GOOS=windows go build ./... and go vet on the changed packages pass. (make lint itself can't run on the machine this was checked on: prek's hook runs Go 1.26.2, which v2's go.mod rejects. The same golangci-lint version was run directly instead.)

jeremybeard and others added 3 commits October 21, 2026 21:03
Brings in #2407 as a parent only: every file it touches moved on v2,
so the merge keeps v2's tree and the next commit ports it.

Co-Authored-By: Claude <noreply@anthropic.com>
…PI token's organization can't be looked up

The same change as main's, on v2's layout: pkg/httputil/retry.go as is,
the v1 and v1alpha1 constructors in internal/platform/astro/clients
(NewV1ClientForLogin too, which main does not have), the sentinel in
cmd/astro/setup.go, and the hook in cmd/root_hooks.go.

One difference: astro auth token, which only v2 has, keeps working when
the lookup fails. The token is saved before the lookup and printing it
needs no organization; TestPreRunLeavesJSONStdoutAlone holds it.

Co-Authored-By: Claude <noreply@anthropic.com>
@coveralls-official

coveralls-official Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39806272762

Coverage increased (+0.03%) to 60.602%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 8 uncovered changes across 2 files (56 of 64 lines covered, 87.5%).
  • 2 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
cmd/astro/setup.go 27 21 77.78%
internal/platform/astro/clients/astrov1/client.go 2 0 0.0%
Total (6 files) 64 56 87.5%

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
cmd/astro/setup.go 2 79.86%

Coverage Stats

Coverage Status
Relevant Lines: 68546
Covered Lines: 41540
Line Coverage: 60.6%
Coverage Strength: 408.23 hits per line

💛 - Coveralls

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
schnie merged commit eaf952c into v2 Oct 22, 2026
7 checks passed
@schnie
schnie deleted the sync/main-into-v2-2026-10-21c branch October 22, 2026 16:02
@schnie schnie mentioned this pull request Oct 23, 2026
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