Repository navigation
auth: read auth_storage from the config file the profile was loaded from - #7733
Merged
Merged
Conversation
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>
Collaborator
✅ Integration test reportCommit: 084cf2a
Top 3 slowest tests (at least 2 minutes):
|
anton-107
approved these changes
Nov 19, 2026
anton-107
left a comment
Contributor
There was a problem hiding this comment.
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:150setsConfigFileto$HOME/.databrickscfg, so the env loaders never override it. WhenDATABRICKS_CONFIG_FILEis set, labs now readsauth_storagefrom 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~/.databrickscfgwhen the field is empty, but storage still comes fromDATABRICKS_CONFIG_FILE. The two only differ for configs whoseLoadersskip the env loaders. The description already covers this under "Decisions to review", so a follow-up is fine.
Member
Author
|
Thanks! The description now mentions the labs change. The empty |
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.
The CLI read the token storage mode (
auth_storage) from the file named byDATABRICKS_CONFIG_FILE, even when the profile was loaded from a different config file. A config built with an explicitConfigFilecould therefore take its storage mode from the wrong file.Changes
CLICredentials.Configurepasses the config'sConfigFileto the storage lookup when it is set, so the storage mode comes from the same file as the profile.ConfigFilekeeps the existing lookup throughDATABRICKS_CONFIG_FILE.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.cmd/labs/project/entrypoint.gosetsConfigFileto$HOME/.databrickscfg, so withDATABRICKS_CONFIG_FILEset, labs now readsauth_storagefrom the home file, which is where labs loads its profile from.Why
The SDK calls
Configurewith 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
env.Seton a context used only for the storage lookup. The alternative is a path parameter onstorage.ResolveStore, which would change the signature used by the other callers. This change stays in one function.ConfigFilestill usesDATABRICKS_CONFIG_FILE. Reading the default file instead would change behavior for callers that do not set the field.Tests
TestCLICredentialsConfigure_StorageModeFollowsConfigFilecovers both directions. WithDATABRICKS_CONFIG_FILEnaming a file with an invalidauth_storage, Configure succeeds when the config's file setsplaintext. 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.This pull request and its description were written by Isaac.