Skip to content

auth: read auth_storage from the config file the profile was loaded from - #7733

Merged
simonfaltum merged 2 commits into
mainfrom
auth-store-config-file
Nov 19, 2026
Merged

simonfaltum merged 2 commits into
mainfrom
auth-store-config-file

Conversation

@simonfaltum

@simonfaltum simonfaltum commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

The CLI read the token storage mode (auth_storage) from the file named by DATABRICKS_CONFIG_FILE, even when the profile was loaded from a different config file. A config built with an explicit ConfigFile could therefore take its storage mode from the wrong file.

Changes

  • CLICredentials.Configure passes the config's ConfigFile to the storage lookup when it is set, so the storage mode comes from the same file as the profile.
  • An empty ConfigFile keeps the existing lookup through DATABRICKS_CONFIG_FILE.
  • The other callers (auth login, auth logout, auth token, and the Docker credential helper) are unchanged. They read the profile and the storage mode from the same environment-named file.
  • The one production caller whose behavior changes is labs. cmd/labs/project/entrypoint.go sets ConfigFile to $HOME/.databrickscfg, so with DATABRICKS_CONFIG_FILE set, labs now reads auth_storage from the home file, which is where labs loads its profile from.

Why

The SDK calls Configure with its own background context, so env overrides set on the caller's context do not reach it. The storage lookup then falls back to the process environment. Code that loads a profile from a specific file, without changing the process environment, got the storage mode from another file.

Decisions to review

  • The override is an env.Set on a context used only for the storage lookup. The alternative is a path parameter on storage.ResolveStore, which would change the signature used by the other callers. This change stays in one function.
  • An empty ConfigFile still uses DATABRICKS_CONFIG_FILE. Reading the default file instead would change behavior for callers that do not set the field.

Tests

  • TestCLICredentialsConfigure_StorageModeFollowsConfigFile covers both directions. With DATABRICKS_CONFIG_FILE naming a file with an invalid auth_storage, Configure succeeds when the config's file sets plaintext. With the roles reversed, it fails on the config's invalid value. Both cases fail without this change.
  • go test ./libs/auth/... ./cmd/auth/... ./libs/databrickscfg/... pass.
  • Not tested: secure (keyring) mode through this path, because the unit test does not use an OS keyring.

This pull request and its description were written by Isaac.

simonfaltum and others added 2 commits November 17, 2026 21:25
CLICredentials.Configure resolved the token storage mode through
storage.ResolveStore, which reads [__settings__] auth_storage from
DATABRICKS_CONFIG_FILE. A config built with its own ConfigFile, such as
one loaded from a pinned file, then took its storage mode from a different
file whenever the environment named another one. The SDK calls Configure
with a background context, so env overrides from the caller did not apply.

Configure now passes the config's ConfigFile to the storage lookup when it
is set. An empty ConfigFile keeps the existing lookup.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added the auth label Nov 17, 2026
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 084cf2a

Run: 44180233474

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 270 15 5:51
💚​ aws-windows-latest-4core-16gb 1 272 13 5:29
💚​ azure linux-2core-8gb 1 269 15 5:09
💚​ azure-windows-latest-4core-16gb 1 271 13 4:35
💚​ gcp linux-2core-8gb 1 270 15 7:24
💚​ gcp-windows-latest-4core-16gb 1 272 13 5:42
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:39 aws-windows-latest-4core-16gb TestAccept
3:32 gcp-windows-latest-4core-16gb TestAccept
3:06 azure-windows-latest-4core-16gb TestAccept

@simonfaltum
simonfaltum marked this pull request as ready for review November 18, 2026 16:21
@simonfaltum
simonfaltum requested review from a team as code owners November 18, 2026 16:21

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good to me — no issues found.

@anton-107 anton-107 left a comment

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.

LGTM. Small, read-only change in one function, easy to revert. I checked that both new subtests fail on the base commit and pass with the fix, and that libs/auth/..., cmd/auth/..., cmd/labs/..., cmd/root/... and libs/databrickscfg/... pass locally.

Non-blocking notes:

  • Labs behavior changes. cmd/labs/project/entrypoint.go:150 sets ConfigFile to $HOME/.databrickscfg, so the env loaders never override it. When DATABRICKS_CONFIG_FILE is set, labs now reads auth_storage from the home file instead of the env file. That matches where labs loads its profile, so I think it's the right direction. It's the one production caller whose behavior changes, though, so it could get a line in the description.
  • Empty ConfigFile. The SDK loads the profile from ~/.databrickscfg when the field is empty, but storage still comes from DATABRICKS_CONFIG_FILE. The two only differ for configs whose Loaders skip the env loaders. The description already covers this under "Decisions to review", so a follow-up is fine.

@simonfaltum

Copy link
Copy Markdown
Member Author

Thanks! The description now mentions the labs change. The empty ConfigFile case stays a follow-up, as you say.

@simonfaltum
simonfaltum added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 0fd829f Nov 19, 2026
31 of 32 checks passed
@simonfaltum
simonfaltum deleted the auth-store-config-file branch November 19, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants