Skip to content

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

Merged
janniklasrose merged 3 commits into
mainfrom
janniklasrose/auth-profile-timeout
Jul 21, 2026
Merged

auth: bound per-profile validation with a 10s timeout#5928
janniklasrose merged 3 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
@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 Outdated
Comment thread cmd/auth/profiles.go Outdated
@janniklasrose
janniklasrose enabled auto-merge July 21, 2026 10:21
@janniklasrose
janniklasrose added this pull request to the merge queue Jul 21, 2026
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: d202457

Run: 29821925271

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 227 1127 3:05
💚​ aws windows 4 4 229 1125 3:06
💚​ aws-ucws linux 4 4 314 1044 6:22
💚​ aws-ucws windows 4 4 316 1042 4:50
💚​ azure linux 4 4 227 1126 3:24
💚​ azure windows 4 4 229 1124 2:38
💚​ azure-ucws linux 4 4 316 1041 6:02
🔄​ azure-ucws windows 2 4 4 316 1039 4:31
💚​ gcp linux 4 4 226 1128 2:59
💚​ gcp windows 4 4 228 1126 2:52
10 interesting tests: 4 RECOVERED, 4 SKIP, 2 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestFilerWorkspaceNotebook ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p
🔄​ TestFilerWorkspaceNotebook/rJupyterNb.ipynb ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R

Merged via the queue into main with commit b240ea8 Jul 21, 2026
24 checks passed
@janniklasrose
janniklasrose deleted the janniklasrose/auth-profile-timeout branch July 21, 2026 10:58
@@ -0,0 +1 @@
* `databricks auth profiles` no longer stalls on an unreachable workspace. Each profile is now validated with a 10s timeout (also applied to the host-metadata fetch in `EnsureResolved`), so a host the SDK would otherwise retry — connection refused, connect/TLS timeout, or a retriable 5xx — can't block the whole listing for the SDK's default ~5-minute retry budget.

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.

Nit: outdated changelog with 5s change.

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.

4 participants