Fix CLI token source --profile fallback with version detection#751
Open
mihaimitrea-db wants to merge 1 commit intomainfrom
Open
Fix CLI token source --profile fallback with version detection#751mihaimitrea-db wants to merge 1 commit intomainfrom
mihaimitrea-db wants to merge 1 commit intomainfrom
Conversation
048a903 to
5e8f476
Compare
Contributor
Author
Range-diff: main (048a903 -> 5e8f476)
Reproduce locally: |
5e8f476 to
6b8a57f
Compare
Contributor
Author
Range-diff: main (5e8f476 -> 6b8a57f)
Reproduce locally: |
6b8a57f to
61686da
Compare
Contributor
Author
Range-diff: main (6b8a57f -> 61686da)
Reproduce locally: |
61686da to
1c68e85
Compare
Contributor
Author
Range-diff: main (61686da -> 1c68e85)
Reproduce locally: |
1c68e85 to
0de2614
Compare
0de2614 to
6d775fc
Compare
`--profile` on `databricks auth token` is a global Cobra flag, so old CLIs (< v0.207.1) silently accept it and fail later with `cannot fetch credentials` instead of `unknown flag: --profile`. The previous error-based fallback never matched, leaving the `--host` fallback as dead code. This commit replaces the runtime fallback chain with version-based capability detection: * `CliVersion` carries a (major, minor, patch) triple plus an `UNKNOWN` sentinel and a default-dev-build (0,0,0) check. * `DatabricksCliCredentialsProvider` runs `databricks version --output json` once per CLI path (cached on success only, with a 5s timeout) and gates `--profile` on >= v0.207.1; everything else falls back to `--host` with a precise warning. * `CliTokenSource` is simplified to a single `cmd`; the `fallbackCmd` parameter and the runtime "unknown flag" retry loop are removed. Mirrors the equivalent refactors in the Go and Python SDKs: * databricks/databricks-sdk-go#1605 * databricks/databricks-sdk-py#1377 Co-authored-by: Isaac
6d775fc to
c4e12c1
Compare
Contributor
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
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.
🥞 Stacked PR
Use this link to review incremental changes.
Summary
Replace the broken error-based
--profilefallback inCliTokenSourcewith version-based CLI detection at init time. Mirrors databricks/databricks-sdk-go#1605 and databricks/databricks-sdk-py#1377.Why
--profileondatabricks auth tokenis a global flag, so old CLIs (< v0.207.1) silently accept it and then fail with"cannot fetch credentials"instead of"unknown flag: --profile". The existing retry check was matching on the latter and never fired — the--hostfallback it gated was effectively dead code. Switching todatabricks version+ a minimum-version constant makes the fallback reliable and sets up future capability-gated flags (e.g.--force-refreshin #752) without additional subprocess calls.What changed
Interface changes
None.
CliTokenSourceis not part of the public API surface.Behavioral changes
cfg.profile+ CLI < v0.207.1 now correctly falls back to--host(previously broken).databricks versionfailures log aWARNINGand fall back to the most conservative command. Successful detections are cached per CLI path; failures are not cached and will be retried on the next call.v0.0.0-dev) logs anINFOexplaining why feature gates are conservative.AzureCliCredentialsProvideris untouched.Internal changes
DatabricksCliVersionclass with a(major, minor, patch)triple, anUNKNOWNsentinel, anatLeast()comparator, and anisDefaultDevBuild()helper.CliTokenSourcesimplified to a singlecmd; thefallbackCmdparameter and its retry logic are removed.DatabricksCliCredentialsProvidergainsgetCliVersion,probeCliVersion,parseCliVersion,resolveCliCommand, andbuildCliCommandhelpers.How is this tested?
Unit tests in
DatabricksCliVersionTestcover version comparison (across patch/minor/major), theUNKNOWNsentinel, dev-build detection, andtoStringformatting.Unit tests in
DatabricksCliCredentialsProviderTestcover JSON parsing ofdatabricks version --output json(standard, dev build, missing fields, malformed JSON, empty string) and command assembly for every profile/host/version combination (host-only, account host, profile + new CLI, profile + old CLI, unknown version, dev build).CliTokenSourceTestretains its parsing and timezone tests; the obsolete fallback tests are dropped.