diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index b406a874e8..ff3d36343a 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -5,6 +5,7 @@ ### Notable Changes ### CLI +* Auth commands now error when --profile and --host conflict ([#4841](https://github.com/databricks/cli/pull/4841)) ### Bundles * engine/direct: Fix drift in grants resource due to privilege reordering ([#4794](https://github.com/databricks/cli/pull/4794)) diff --git a/acceptance/cmd/auth/login/custom-config-file/out.databrickscfg b/acceptance/cmd/auth/login/custom-config-file/out.databrickscfg deleted file mode 100644 index 2097f1a344..0000000000 --- a/acceptance/cmd/auth/login/custom-config-file/out.databrickscfg +++ /dev/null @@ -1,7 +0,0 @@ -; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. -[DEFAULT] - -[custom-test] -host = [DATABRICKS_URL] -auth_type = databricks-cli -workspace_id = [NUMID] diff --git a/acceptance/cmd/auth/login/custom-config-file/output.txt b/acceptance/cmd/auth/login/custom-config-file/output.txt index f6657d7c6f..c586e020df 100644 --- a/acceptance/cmd/auth/login/custom-config-file/output.txt +++ b/acceptance/cmd/auth/login/custom-config-file/output.txt @@ -5,18 +5,8 @@ host = https://old-host.cloud.databricks.com auth_type = pat token = old-token-123 -=== Login with new host (should override old host) +=== Login with conflicting host (should error) >>> [CLI] auth login --host [DATABRICKS_URL] --profile custom-test -Profile custom-test was successfully saved +Error: --profile "custom-test" has host "https://old-host.cloud.databricks.com", which conflicts with --host "[DATABRICKS_URL]". Use --profile only to select a profile -=== Default config file should NOT exist -OK: Default .databrickscfg does not exist - -=== Custom config file after login (old host should be replaced) -; The profile defined in the DEFAULT section is to be used as a fallback when no profile is explicitly specified. -[DEFAULT] - -[custom-test] -host = [DATABRICKS_URL] -auth_type = databricks-cli -workspace_id = [NUMID] +Exit code: 1 diff --git a/acceptance/cmd/auth/login/custom-config-file/script b/acceptance/cmd/auth/login/custom-config-file/script index 8be849974e..6e7aeb6c6a 100644 --- a/acceptance/cmd/auth/login/custom-config-file/script +++ b/acceptance/cmd/auth/login/custom-config-file/script @@ -8,9 +8,7 @@ export BROWSER="browser.py" export DATABRICKS_CONFIG_FILE="./home/custom.databrickscfg" # Create an existing custom config file with a DIFFERENT host. -# The login command should use the host from --host argument, NOT from this file. -# If the wrong host (from the config file) were used, the OAuth flow would fail -# because the mock server only responds for $DATABRICKS_HOST. +# Since --profile and --host conflict, the CLI should error. cat > "./home/custom.databrickscfg" <