From ce3ade6a851e67eb8f79d10416d987a57cb360f9 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Fri, 8 May 2026 20:34:16 +0200 Subject: [PATCH 1/6] Fix acceptance sethome to export an absolute HOME sethome exported HOME (and USERPROFILE) as the relative path the caller passed in (typically "./home"). The SDK expands `~/.databrickscfg` against $HOME at lookup time, so the moment a test cd's into a child directory, the cfg "disappears": helpers like databrickscfg.GetConfiguredDefaultProfile silently return "" because the relative path no longer points at a real file. That made it easy to write tests that look like they exercise default_profile resolution but actually only succeed because the cfg lookup short-circuits. Resolve $1 to an absolute path with `cd && pwd` (portable on macOS/Linux/Windows-MSYS) before exporting. With this fix, the acceptance/auth/bundle_default_profile "workspace.profile pinned" sub-case correctly fails when the Workspace.Profile == "" guard in cmd/root/bundle.go configureProfile is removed; previously it passed either way. Output for the same directory's "Bundle with workspace.host" sub-case also changes: with the cfg now reachable from the bundle subdir, the SDK's host-based lookup finds the matching profile and validate succeeds instead of failing with "default auth: cannot configure default credentials". Co-authored-by: Isaac --- acceptance/auth/bundle_default_profile/output.txt | 6 +----- acceptance/script.prepare | 8 ++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/acceptance/auth/bundle_default_profile/output.txt b/acceptance/auth/bundle_default_profile/output.txt index 8a2e034f240..f8e8a3c0062 100644 --- a/acceptance/auth/bundle_default_profile/output.txt +++ b/acceptance/auth/bundle_default_profile/output.txt @@ -23,10 +23,6 @@ Exit code: 1 === Bundle with workspace.host: default_profile is NOT applied >>> errcode [CLI] bundle validate -o json -Error: failed during request visitor: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: host=[DATABRICKS_URL], workspace_id=[NUMID], databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH - - -Exit code: 1 { "host": "[DATABRICKS_URL]", "profile": null @@ -35,7 +31,7 @@ Exit code: 1 === Bundle with workspace.profile: pinned profile wins over default_profile >>> errcode [CLI] bundle validate -o json -Error: failed during request visitor: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: profile=other, databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH +Error: Get "https://other.test/api/2.0/preview/scim/v2/Me": (redacted) Exit code: 1 diff --git a/acceptance/script.prepare b/acceptance/script.prepare index b158ca3c74e..c4be7f709fd 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -101,6 +101,14 @@ sethome() { local home="$1" mkdir -p "$home" + # Resolve to an absolute path so HOME (and USERPROFILE) keep pointing at + # the same directory after the test cd's elsewhere. The SDK expands + # `~/.databrickscfg` against $HOME at lookup time; with a relative path + # the cfg silently disappears once the cwd changes, and helpers like + # databrickscfg.GetConfiguredDefaultProfile return "" instead of + # erroring. `cd && pwd` is portable across macOS/Linux/Windows-MSYS. + home="$(cd "$home" && pwd)" + # For macOS and Linux, use HOME. export HOME="$home" From ea12c227faf90f1a60f6b78e17144e960ba78e01 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Mon, 18 May 2026 13:27:07 +0200 Subject: [PATCH 2/6] Regenerate acceptance outputs after sethome HOME fix 81d9297df changed sethome to export an absolute HOME so the SDK can locate ~/.databrickscfg after a test cd's. The SDK now reports paths relative to the absolute HOME, which surfaces in user-visible output as [TEST_TMP_DIR]/home/.databrickscfg (or [HOME]/.zshrc where the test registers a HOME replacement). The four committed outputs predated the fix and still expected the relative ./home form; regenerated with ./task test-update. Co-authored-by: Isaac --- .../describe/u2m-plaintext-config/output.txt | 6 +++--- .../describe/u2m-plaintext-default/output.txt | 4 ++-- .../auth/describe/u2m-plaintext-env/output.txt | 4 ++-- acceptance/cmd/completion/output.txt | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt index 37a44d830f8..d1e522be97b 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt @@ -2,11 +2,11 @@ >>> [CLI] auth describe --profile u2m-profile Warn: [hostmetadata] failed to fetch host metadata for https://u2m-profile.databricks.test, will skip for 1m0s Unable to authenticate: error getting token: cache: token not found -Token storage: plaintext, ~/.databricks/token-cache.json (from auth_storage in [__settings__] section of home/.databrickscfg) +Token storage: plaintext, ~/.databricks/token-cache.json (from auth_storage in [__settings__] section of [TEST_TMP_DIR]/home/.databrickscfg) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt index 981244ff8d9..004cc787aaa 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt @@ -5,8 +5,8 @@ Unable to authenticate: error getting token: cache: token not found Token storage: plaintext, ~/.databricks/token-cache.json (from default) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt index ff36f25245d..edfdc0a1939 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt @@ -5,8 +5,8 @@ Unable to authenticate: error getting token: cache: token not found Token storage: plaintext, ~/.databricks/token-cache.json (from DATABRICKS_AUTH_STORAGE environment variable) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/completion/output.txt b/acceptance/cmd/completion/output.txt index 17ed0f61eb0..d9e58987459 100644 --- a/acceptance/cmd/completion/output.txt +++ b/acceptance/cmd/completion/output.txt @@ -1,34 +1,34 @@ >>> [CLI] completion install --shell zsh --auto-approve Databricks CLI completions installed for zsh. -Restart your shell or run 'source home/.zshrc' to activate. +Restart your shell or run 'source [HOME]/.zshrc' to activate. Warning: zsh completions require the completion system to be initialized. -Add the following to your home/.zshrc: +Add the following to your [HOME]/.zshrc: autoload -U compinit && compinit >>> [CLI] completion status --shell zsh Shell: zsh -File: home/.zshrc +File: [HOME]/.zshrc Status: installed Warning: zsh completions require the completion system to be initialized. -Add the following to your home/.zshrc: +Add the following to your [HOME]/.zshrc: autoload -U compinit && compinit >>> [CLI] completion install --shell zsh --auto-approve -Databricks CLI completions are already installed for zsh in home/.zshrc. +Databricks CLI completions are already installed for zsh in [HOME]/.zshrc. Warning: zsh completions require the completion system to be initialized. -Add the following to your home/.zshrc: +Add the following to your [HOME]/.zshrc: autoload -U compinit && compinit >>> [CLI] completion uninstall --shell zsh --auto-approve -Databricks CLI completions removed for zsh from home/.zshrc. +Databricks CLI completions removed for zsh from [HOME]/.zshrc. >>> [CLI] completion status --shell zsh Shell: zsh -File: home/.zshrc +File: [HOME]/.zshrc Status: not installed # bash completion V2 for databricks -*- shell-script -*- #compdef databricks From 1f5953cf97d80c1f01388984980f345bc2af7d25 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Mon, 18 May 2026 15:23:14 +0200 Subject: [PATCH 3/6] Fix acceptance sethome USERPROFILE on Git Bash (Windows) The previous fix resolved $home with `cd && pwd` to give HOME and USERPROFILE an absolute path. On Git Bash (MSYS), plain `pwd` returns Unix-style /c/... paths that the native Windows Go binary can't open, so the SDK silently fails to load ~/.databrickscfg and tests like cmd/api/default-profile (no auth resolves) and cmd/api/workspace-id-none (profile not read; SDK back-fills WorkspaceID from host metadata) fail on Windows only. Use `pwd -W` for USERPROFILE on MSYS/Cygwin to emit the mixed C:/... form Windows file APIs accept. HOME keeps the Unix-style path bash itself wants. Co-authored-by: Isaac --- acceptance/script.prepare | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/acceptance/script.prepare b/acceptance/script.prepare index c4be7f709fd..d4e40c5afa1 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -106,14 +106,19 @@ sethome() { # `~/.databrickscfg` against $HOME at lookup time; with a relative path # the cfg silently disappears once the cwd changes, and helpers like # databrickscfg.GetConfiguredDefaultProfile return "" instead of - # erroring. `cd && pwd` is portable across macOS/Linux/Windows-MSYS. - home="$(cd "$home" && pwd)" + # erroring. # For macOS and Linux, use HOME. - export HOME="$home" + export HOME="$(cd "$home" && pwd)" - # For Windows, use USERPROFILE. - export USERPROFILE="$home" + # For Windows, use USERPROFILE. On Git Bash (MSYS), plain `pwd` returns + # Unix-style /c/... paths that the native Windows Go binary can't open; + # `pwd -W` returns the mixed C:/... form instead. + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then + export USERPROFILE="$(cd "$home" && pwd -W)" + else + export USERPROFILE="$(cd "$home" && pwd)" + fi } as-test-sp() { From 9f3ddf55fd24c78f5bd42eaf2fd233e83c97c5cc Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Tue, 19 May 2026 10:13:19 +0200 Subject: [PATCH 4/6] Revert sethome absolute-path fix and regenerated outputs The absolute-path resolution (cd && pwd) introduced in 81d9297df works on macOS/Linux but emits Unix-style /c/... paths on Git Bash, which the native Windows Go binary can't open; the follow-up adb452f58 fixed the CLI path with `pwd -W` but broke tests like cmd/completion that compare the bash $HOME placeholder against the CLI's USERPROFILE-derived output. Revert sethome to the original simple form and restore the four outputs regenerated in f893006c8 to their pre-fix relative-./home forms. bundle_default_profile keeps its sub-cases but the cd'ing variants short-circuit on a missing cfg again (same expected output as before 81d9297df). A separate PR will revisit the test setup to make absolute HOME work cleanly across platforms. Co-authored-by: Isaac --- .../auth/bundle_default_profile/output.txt | 6 +++++- .../describe/u2m-plaintext-config/output.txt | 6 +++--- .../describe/u2m-plaintext-default/output.txt | 4 ++-- .../describe/u2m-plaintext-env/output.txt | 4 ++-- acceptance/cmd/completion/output.txt | 16 ++++++++-------- acceptance/script.prepare | 19 +++---------------- 6 files changed, 23 insertions(+), 32 deletions(-) diff --git a/acceptance/auth/bundle_default_profile/output.txt b/acceptance/auth/bundle_default_profile/output.txt index f8e8a3c0062..8a2e034f240 100644 --- a/acceptance/auth/bundle_default_profile/output.txt +++ b/acceptance/auth/bundle_default_profile/output.txt @@ -23,6 +23,10 @@ Exit code: 1 === Bundle with workspace.host: default_profile is NOT applied >>> errcode [CLI] bundle validate -o json +Error: failed during request visitor: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: host=[DATABRICKS_URL], workspace_id=[NUMID], databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH + + +Exit code: 1 { "host": "[DATABRICKS_URL]", "profile": null @@ -31,7 +35,7 @@ Exit code: 1 === Bundle with workspace.profile: pinned profile wins over default_profile >>> errcode [CLI] bundle validate -o json -Error: Get "https://other.test/api/2.0/preview/scim/v2/Me": (redacted) +Error: failed during request visitor: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: profile=other, databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH Exit code: 1 diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt index d1e522be97b..37a44d830f8 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt @@ -2,11 +2,11 @@ >>> [CLI] auth describe --profile u2m-profile Warn: [hostmetadata] failed to fetch host metadata for https://u2m-profile.databricks.test, will skip for 1m0s Unable to authenticate: error getting token: cache: token not found -Token storage: plaintext, ~/.databricks/token-cache.json (from auth_storage in [__settings__] section of [TEST_TMP_DIR]/home/.databrickscfg) +Token storage: plaintext, ~/.databricks/token-cache.json (from auth_storage in [__settings__] section of home/.databrickscfg) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt index 004cc787aaa..981244ff8d9 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt @@ -5,8 +5,8 @@ Unable to authenticate: error getting token: cache: token not found Token storage: plaintext, ~/.databricks/token-cache.json (from default) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt index edfdc0a1939..ff36f25245d 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt @@ -5,8 +5,8 @@ Unable to authenticate: error getting token: cache: token not found Token storage: plaintext, ~/.databricks/token-cache.json (from DATABRICKS_AUTH_STORAGE environment variable) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/completion/output.txt b/acceptance/cmd/completion/output.txt index d9e58987459..17ed0f61eb0 100644 --- a/acceptance/cmd/completion/output.txt +++ b/acceptance/cmd/completion/output.txt @@ -1,34 +1,34 @@ >>> [CLI] completion install --shell zsh --auto-approve Databricks CLI completions installed for zsh. -Restart your shell or run 'source [HOME]/.zshrc' to activate. +Restart your shell or run 'source home/.zshrc' to activate. Warning: zsh completions require the completion system to be initialized. -Add the following to your [HOME]/.zshrc: +Add the following to your home/.zshrc: autoload -U compinit && compinit >>> [CLI] completion status --shell zsh Shell: zsh -File: [HOME]/.zshrc +File: home/.zshrc Status: installed Warning: zsh completions require the completion system to be initialized. -Add the following to your [HOME]/.zshrc: +Add the following to your home/.zshrc: autoload -U compinit && compinit >>> [CLI] completion install --shell zsh --auto-approve -Databricks CLI completions are already installed for zsh in [HOME]/.zshrc. +Databricks CLI completions are already installed for zsh in home/.zshrc. Warning: zsh completions require the completion system to be initialized. -Add the following to your [HOME]/.zshrc: +Add the following to your home/.zshrc: autoload -U compinit && compinit >>> [CLI] completion uninstall --shell zsh --auto-approve -Databricks CLI completions removed for zsh from [HOME]/.zshrc. +Databricks CLI completions removed for zsh from home/.zshrc. >>> [CLI] completion status --shell zsh Shell: zsh -File: [HOME]/.zshrc +File: home/.zshrc Status: not installed # bash completion V2 for databricks -*- shell-script -*- #compdef databricks diff --git a/acceptance/script.prepare b/acceptance/script.prepare index d4e40c5afa1..b158ca3c74e 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -101,24 +101,11 @@ sethome() { local home="$1" mkdir -p "$home" - # Resolve to an absolute path so HOME (and USERPROFILE) keep pointing at - # the same directory after the test cd's elsewhere. The SDK expands - # `~/.databrickscfg` against $HOME at lookup time; with a relative path - # the cfg silently disappears once the cwd changes, and helpers like - # databrickscfg.GetConfiguredDefaultProfile return "" instead of - # erroring. - # For macOS and Linux, use HOME. - export HOME="$(cd "$home" && pwd)" + export HOME="$home" - # For Windows, use USERPROFILE. On Git Bash (MSYS), plain `pwd` returns - # Unix-style /c/... paths that the native Windows Go binary can't open; - # `pwd -W` returns the mixed C:/... form instead. - if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then - export USERPROFILE="$(cd "$home" && pwd -W)" - else - export USERPROFILE="$(cd "$home" && pwd)" - fi + # For Windows, use USERPROFILE. + export USERPROFILE="$home" } as-test-sp() { From b34db383c2e018988a6743394c52ebe5fd3eead0 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Tue, 19 May 2026 10:26:38 +0200 Subject: [PATCH 5/6] Make acceptance sethome export an absolute HOME (cross-platform) sethome exported HOME (and USERPROFILE) as the relative path the caller passed in (typically "./home"). The SDK expands `~/.databrickscfg` against $HOME at lookup time, so the moment a test cd's into a child directory the cfg "disappears": helpers like databrickscfg.GetConfiguredDefaultProfile silently return "" because the relative path no longer points at a real file. That made it easy to write tests that look like they exercise default_profile resolution but actually only succeed because the cfg lookup short-circuits. Resolve $1 to an absolute path with `cd && pwd` before exporting. On Git Bash (MSYS) plain `pwd` returns Unix-style /c/... paths that the native Windows Go binary can't open, so use `pwd -W` to get the mixed C:/... form. Use the same form for both HOME and USERPROFILE so tests like cmd/completion (which registers `$HOME` as the `[HOME]` replacement) match the CLI's USERPROFILE-derived output on Windows. Regenerate the four affected outputs. Co-authored-by: Isaac --- .../auth/bundle_default_profile/output.txt | 6 +----- .../describe/u2m-plaintext-config/output.txt | 6 +++--- .../describe/u2m-plaintext-default/output.txt | 4 ++-- .../describe/u2m-plaintext-env/output.txt | 4 ++-- acceptance/cmd/completion/output.txt | 16 ++++++++-------- acceptance/script.prepare | 19 +++++++++++++++++++ 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/acceptance/auth/bundle_default_profile/output.txt b/acceptance/auth/bundle_default_profile/output.txt index 8a2e034f240..f8e8a3c0062 100644 --- a/acceptance/auth/bundle_default_profile/output.txt +++ b/acceptance/auth/bundle_default_profile/output.txt @@ -23,10 +23,6 @@ Exit code: 1 === Bundle with workspace.host: default_profile is NOT applied >>> errcode [CLI] bundle validate -o json -Error: failed during request visitor: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: host=[DATABRICKS_URL], workspace_id=[NUMID], databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH - - -Exit code: 1 { "host": "[DATABRICKS_URL]", "profile": null @@ -35,7 +31,7 @@ Exit code: 1 === Bundle with workspace.profile: pinned profile wins over default_profile >>> errcode [CLI] bundle validate -o json -Error: failed during request visitor: default auth: cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method. Config: profile=other, databricks_cli_path=[CLI]. Env: DATABRICKS_CLI_PATH +Error: Get "https://other.test/api/2.0/preview/scim/v2/Me": (redacted) Exit code: 1 diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt index 37a44d830f8..d1e522be97b 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-config/output.txt @@ -2,11 +2,11 @@ >>> [CLI] auth describe --profile u2m-profile Warn: [hostmetadata] failed to fetch host metadata for https://u2m-profile.databricks.test, will skip for 1m0s Unable to authenticate: error getting token: cache: token not found -Token storage: plaintext, ~/.databricks/token-cache.json (from auth_storage in [__settings__] section of home/.databrickscfg) +Token storage: plaintext, ~/.databricks/token-cache.json (from auth_storage in [__settings__] section of [TEST_TMP_DIR]/home/.databrickscfg) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt index 981244ff8d9..004cc787aaa 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-default/output.txt @@ -5,8 +5,8 @@ Unable to authenticate: error getting token: cache: token not found Token storage: plaintext, ~/.databricks/token-cache.json (from default) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt b/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt index ff36f25245d..edfdc0a1939 100644 --- a/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt +++ b/acceptance/cmd/auth/describe/u2m-plaintext-env/output.txt @@ -5,8 +5,8 @@ Unable to authenticate: error getting token: cache: token not found Token storage: plaintext, ~/.databricks/token-cache.json (from DATABRICKS_AUTH_STORAGE environment variable) ----- Current configuration: - ✓ host: https://u2m-profile.databricks.test (from ./home/.databrickscfg config file) + ✓ host: https://u2m-profile.databricks.test (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ profile: u2m-profile (from --profile flag) ✓ databricks_cli_path: [CLI] - ✓ auth_type: databricks-cli (from ./home/.databrickscfg config file) + ✓ auth_type: databricks-cli (from [TEST_TMP_DIR]/home/.databrickscfg config file) ✓ rate_limit: [NUMID] (from DATABRICKS_RATE_LIMIT environment variable) diff --git a/acceptance/cmd/completion/output.txt b/acceptance/cmd/completion/output.txt index 17ed0f61eb0..d9e58987459 100644 --- a/acceptance/cmd/completion/output.txt +++ b/acceptance/cmd/completion/output.txt @@ -1,34 +1,34 @@ >>> [CLI] completion install --shell zsh --auto-approve Databricks CLI completions installed for zsh. -Restart your shell or run 'source home/.zshrc' to activate. +Restart your shell or run 'source [HOME]/.zshrc' to activate. Warning: zsh completions require the completion system to be initialized. -Add the following to your home/.zshrc: +Add the following to your [HOME]/.zshrc: autoload -U compinit && compinit >>> [CLI] completion status --shell zsh Shell: zsh -File: home/.zshrc +File: [HOME]/.zshrc Status: installed Warning: zsh completions require the completion system to be initialized. -Add the following to your home/.zshrc: +Add the following to your [HOME]/.zshrc: autoload -U compinit && compinit >>> [CLI] completion install --shell zsh --auto-approve -Databricks CLI completions are already installed for zsh in home/.zshrc. +Databricks CLI completions are already installed for zsh in [HOME]/.zshrc. Warning: zsh completions require the completion system to be initialized. -Add the following to your home/.zshrc: +Add the following to your [HOME]/.zshrc: autoload -U compinit && compinit >>> [CLI] completion uninstall --shell zsh --auto-approve -Databricks CLI completions removed for zsh from home/.zshrc. +Databricks CLI completions removed for zsh from [HOME]/.zshrc. >>> [CLI] completion status --shell zsh Shell: zsh -File: home/.zshrc +File: [HOME]/.zshrc Status: not installed # bash completion V2 for databricks -*- shell-script -*- #compdef databricks diff --git a/acceptance/script.prepare b/acceptance/script.prepare index b158ca3c74e..a8ea942bb46 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -101,6 +101,25 @@ sethome() { local home="$1" mkdir -p "$home" + # Resolve to an absolute path so HOME (and USERPROFILE) keep pointing at + # the same directory after the test cd's elsewhere. The SDK expands + # `~/.databrickscfg` against $HOME at lookup time; with a relative path + # the cfg silently disappears once the cwd changes, and helpers like + # databrickscfg.GetConfiguredDefaultProfile return "" instead of + # erroring. + # + # On Git Bash (MSYS), plain `pwd` returns Unix-style /c/... paths that + # the native Windows Go binary can't open; `pwd -W` returns the mixed + # C:/... form instead. Use the same form for both HOME and USERPROFILE + # so tests that compare a `$HOME`-based placeholder against the CLI's + # `os.UserHomeDir()` output (which reads USERPROFILE on Windows) find + # a match. + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then + home="$(cd "$home" && pwd -W)" + else + home="$(cd "$home" && pwd)" + fi + # For macOS and Linux, use HOME. export HOME="$home" From cde430578896f8bf81b146dadb3badac26d1c182 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Tue, 19 May 2026 15:07:22 +0200 Subject: [PATCH 6/6] acceptance: use templates for bundle_default_profile scenarios Replace inline heredocs and per-scenario subdirectories (./bundle-with-host, ./bundle-with-profile) with three committed template files: databricks.yml.{no-host,with-host,with-profile}.tmpl. The script copies (or envsubsts, for the host-pinned template) the active template into databricks.yml before each phase, so the active bundle is always at the test root. Follows pietern's suggestion in #5214. Co-authored-by: Isaac --- ...bricks.yml => databricks.yml.no-host.tmpl} | 0 .../databricks.yml.with-host.tmpl | 5 ++++ .../databricks.yml.with-profile.tmpl | 5 ++++ acceptance/auth/bundle_default_profile/script | 26 +++++-------------- .../auth/bundle_default_profile/test.toml | 3 +-- 5 files changed, 17 insertions(+), 22 deletions(-) rename acceptance/auth/bundle_default_profile/{databricks.yml => databricks.yml.no-host.tmpl} (100%) create mode 100644 acceptance/auth/bundle_default_profile/databricks.yml.with-host.tmpl create mode 100644 acceptance/auth/bundle_default_profile/databricks.yml.with-profile.tmpl diff --git a/acceptance/auth/bundle_default_profile/databricks.yml b/acceptance/auth/bundle_default_profile/databricks.yml.no-host.tmpl similarity index 100% rename from acceptance/auth/bundle_default_profile/databricks.yml rename to acceptance/auth/bundle_default_profile/databricks.yml.no-host.tmpl diff --git a/acceptance/auth/bundle_default_profile/databricks.yml.with-host.tmpl b/acceptance/auth/bundle_default_profile/databricks.yml.with-host.tmpl new file mode 100644 index 00000000000..4c2f0748389 --- /dev/null +++ b/acceptance/auth/bundle_default_profile/databricks.yml.with-host.tmpl @@ -0,0 +1,5 @@ +bundle: + name: bundle-with-host + +workspace: + host: $DATABRICKS_HOST diff --git a/acceptance/auth/bundle_default_profile/databricks.yml.with-profile.tmpl b/acceptance/auth/bundle_default_profile/databricks.yml.with-profile.tmpl new file mode 100644 index 00000000000..18e719f0ea8 --- /dev/null +++ b/acceptance/auth/bundle_default_profile/databricks.yml.with-profile.tmpl @@ -0,0 +1,5 @@ +bundle: + name: bundle-with-profile + +workspace: + profile: other diff --git a/acceptance/auth/bundle_default_profile/script b/acceptance/auth/bundle_default_profile/script index 6c54b13c78f..793176c4b52 100644 --- a/acceptance/auth/bundle_default_profile/script +++ b/acceptance/auth/bundle_default_profile/script @@ -20,9 +20,11 @@ unset DATABRICKS_HOST unset DATABRICKS_TOKEN unset DATABRICKS_CONFIG_PROFILE +cp databricks.yml.no-host.tmpl databricks.yml title "Bundle without workspace.host: default_profile is honored\n" trace $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}' +cp databricks.yml.no-host.tmpl databricks.yml title "--profile overrides default_profile (negative case)\n" trace errcode $CLI bundle validate -p other -o json | jq '{host: .workspace.host, profile: .workspace.profile}' @@ -30,29 +32,13 @@ trace errcode $CLI bundle validate -p other -o json | jq '{host: .workspace.host # configureProfile must NOT apply default_profile here, because that would # silently route the user to a profile pointing at a different host than the # bundle declares. -mkdir -p ./bundle-with-host -cat > ./bundle-with-host/databricks.yml < databricks.yml title "Bundle with workspace.host: default_profile is NOT applied\n" -(cd ./bundle-with-host && trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}') +trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}' # Switch to a bundle that pins workspace.profile but no host. The pinned # profile must win over default_profile — configureProfile's guard skips # default_profile when workspace.profile is already set. -mkdir -p ./bundle-with-profile -cat > ./bundle-with-profile/databricks.yml <