Skip to content

auth: bound per-profile validation with a 10s timeout#5928

Open
janniklasrose wants to merge 2 commits into
mainfrom
janniklasrose/auth-profile-timeout
Open

auth: bound per-profile validation with a 10s timeout#5928
janniklasrose wants to merge 2 commits into
mainfrom
janniklasrose/auth-profile-timeout

Conversation

@janniklasrose

Copy link
Copy Markdown
Contributor

Changes

Bound each per-profile validation in databricks auth profiles with a 10s timeout.

auth profiles validates every profile with a live API call (Workspaces.List for account configs, CurrentUser.Me for workspace configs). The SDK retries transient network failures — connection refused, connect/TLS timeout, retriable 5xx — for its default RetryTimeoutSeconds (~5 minutes). So a single unreachable-but-retriable workspace stalls the entire listing for minutes.

  • Wrap each validation call in a context.WithTimeout(ctx, 10s).
  • Set the same value on cfg.HTTPTimeoutSeconds / cfg.RetryTimeoutSeconds, because the host-metadata fetch in EnsureResolved runs on context.Background internally and so can't be reached by the validation call's context — without these it would still retry for ~5 minutes.

Hosts that fail DNS (e.g. a typo'd or reserved hostname) are not retriable and already fail fast; this only bounds the retriable cases.

Why

Users with a decommissioned, firewalled, or otherwise unresponsive workspace in ~/.databrickscfg see auth profiles hang for minutes on that one entry, blocking the whole list. Bounding each validation keeps the command responsive.

Tests

  • TestProfileLoadTimesOutOnUnresponsiveHost (cmd/auth/profiles_test.go) — points a profile at an httptest server that hangs every request until the client cancels, and asserts Load returns bounded rather than retrying to the SDK default. The handler waits on the request context so server.Close doesn't block on a leaked connection. profileValidationTimeout is a var so the test shrinks it (kept ≥1s, since Load derives the SDK's integer-second budgets from it and a sub-second value floors to 0 = "use default").
  • Full cmd/auth package and ./task lint-q pass.

This pull request and its description were written by Isaac, an AI coding agent.

`databricks auth profiles` validates each profile with a live API call
(Workspaces.List or CurrentUser.Me). The SDK retries transient network
failures — connection refused, connect/TLS timeout, retriable 5xx — for
its default RetryTimeoutSeconds (~5 minutes), so a single unreachable
workspace stalls the entire listing. (Hosts that fail DNS are not
retriable and already fail fast; those never stalled.)

Bound each validation with a 10s context timeout, and set the same value
on HTTPTimeoutSeconds/RetryTimeoutSeconds so the host-metadata fetch in
EnsureResolved is bounded too — it runs on context.Background internally,
so the context.WithTimeout on the validation call cannot reach it.

Adds a regression test that points a profile at a server which hangs
until the client cancels and asserts Load returns bounded rather than
retrying to the SDK default. profileValidationTimeout is a var so the
test can shrink it.

Co-authored-by: Isaac
@github-actions

Copy link
Copy Markdown
Contributor

Approval status: pending

/cmd/auth/ - needs approval

Files: cmd/auth/profiles.go, cmd/auth/profiles_test.go
Suggested: @simonfaltum
Also eligible: @mihaimitrea-db, @tanmay-db, @renaudhartert-db, @tejaskochar-db, @hectorcast-db, @parthban-db, @Divyansh-db, @chrisst, @rauchy

General files (require maintainer)

Files: .nextchanges/cli/auth-profiles-timeout.md
Based on git history:

  • @simonfaltum -- recent work in cmd/auth/

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db, @lennartkats-db) can approve all areas.
See OWNERS for ownership rules.

@janniklasrose janniklasrose changed the title auth profiles: bound per-profile validation with a 10s timeout auth: bound per-profile validation with a 10s timeout Jul 15, 2026
Comment thread cmd/auth/profiles.go
// for the SDK's default retry budget (~5 minutes). Hosts that fail DNS are not
// retriable and already fail fast, so this only bounds the retriable cases.
// A var (not const) so tests can shrink it.
var profileValidationTimeout = 10 * time.Second

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why 10 seconds? Other CLI limits seem to be 30 seconds, maybe we should stick to this?

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