Skip to content

Auth: error when --profile and --host conflict - #4841

Merged
simonfaltum merged 8 commits into
mainfrom
simonfaltum/auth-profile-host-conflict
Apr 7, 2026
Merged

Auth: error when --profile and --host conflict#4841
simonfaltum merged 8 commits into
mainfrom
simonfaltum/auth-profile-host-conflict

Conversation

@simonfaltum

Copy link
Copy Markdown
Member

Why

Users can pass both --profile logfood and --host https://other-host.com on auth commands with no validation. The CLI silently picks one based on internal priority, which is confusing.

Changes

Before: databricks auth login --profile logfood --host https://other.com silently uses one of the two with no warning.
Now: produces an error explaining the conflict and suggesting to use --profile alone.

Adds a PersistentPreRunE on the auth parent command that validates when both --profile and --host are explicitly set. If the profile's host matches the --host value (after canonicalization), the command proceeds silently. If they conflict, it returns a clear error.

Test plan

  • New unit tests for validateProfileHostConflict (5 table-driven cases: matching hosts, trailing slash, conflict, profile not found, no host)
  • make checks passes
  • make lintfull passes
  • go test ./cmd/auth/ passes

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Mar 25, 2026

Copy link
Copy Markdown
Collaborator

Commit: 70e8eab

Run: 23621503408

Env💚​RECOVERED🙈​SKIP✅​pass🙈​skipTime
💚​aws linux7102708075:56
💚​aws windows7102728055:03
💚​aws-ucws linux7103667238:41
💚​aws-ucws windows7103687217:24
💚​azure linux1122738057:08
💚​azure windows1122758035:35
💚​azure-ucws linux1123717197:57
💚​azure-ucws windows1123737176:31
💚​gcp linux1122698085:54
💚​gcp windows1122718066:25
17 interesting tests: 10 SKIP, 7 RECOVERED
Test Nameaws linuxaws windowsaws-ucws linuxaws-ucws windowsazure linuxazure windowsazure-ucws linuxazure-ucws windowsgcp linuxgcp windows
💚​TestAccept💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
🙈​TestAccept/bundle/resources/permissions🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
💚​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions💚​R💚​R💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
💚​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions💚​R💚​R💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
💚​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R
🙈​TestAccept/bundle/resources/postgres_branches/basic🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_branches/recreate🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_branches/update_protected🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_branches/without_branch_id🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_endpoints/basic🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_endpoints/recreate🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_projects/update_display_name🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/synced_database_tables/basic🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/ssh/connection🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
Top 20 slowest tests (at least 2 minutes):
durationenvtestname
4:47azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:42gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:19gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
4:08gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:58azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:15azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:12azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:09gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:49aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:48azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:46aws-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:45aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:45aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:42aws-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:42azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:41aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:40aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:39aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:38azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:15azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform

@github-actions

Copy link
Copy Markdown
Contributor

Suggested reviewers

Based on git history of the changed files, these people are best suited to review:

Confidence: high

Eligible reviewers

Based on CODEOWNERS, these people or teams could also review:

@andrewnester, @anton-107, @denik, @shreyas-goenka

Suggestions based on git history of 4 changed files (3 scored). See CODEOWNERS for path-specific ownership rules.

@simonfaltum
simonfaltumforce-pushed the simonfaltum/auth-profile-host-conflict branch from a07aa55 to c758131CompareMarch 26, 2026 22:24
Remove promptForWorkspaceID that was deleted on main but accidentally
reintroduced during rebase. Update the custom-config-file acceptance
test to expect the new profile/host conflict error.
Co-authored-by: Isaac

@mihaimitrea-dbmihaimitrea-db 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 after description is updated

Comment threadcmd/auth/login.go Outdated
Item 3 in the long description still described the old behavior where
conflicting --profile and --host would silently update the profile.
Updated to describe the new error behavior.
Co-authored-by: Isaac
Keep both the new --force-refresh flag from main and the
profileHostConflictCheck PreRunE from this branch.
Co-authored-by: Isaac
@simonfaltum
simonfaltum enabled auto-merge April 7, 2026 12:27
@simonfaltum
simonfaltum added this pull request to the merge queueApr 7, 2026
Merged via the queue into main with commit 49cc72bApr 7, 2026
18 checks passed
@simonfaltum
simonfaltum deleted the simonfaltum/auth-profile-host-conflict branch April 7, 2026 12:53
deco-sdk-taggingBot added a commit that referenced this pull request Apr 8, 2026
## Release v0.296.0
### Notable Changes
* Direct deployment engine for DABs is now in Public Preview. Documentation at [docs/direct.md](docs/direct.md).
### CLI
* Auth commands now error when --profile and --host conflict ([#4841](#4841))
* Add `--force-refresh` flag to `databricks auth token` to force a token refresh even when the cached token is still valid ([#4767](#4767))
### Bundles
* Deduplicate grant entries with duplicate principals or privileges during initialization ([#4801](#4801))
* Fix `bundle deployment bind` to always pull remote state before modifying ([#4892](#4892))
* engine/direct: Fix drift in grants resource due to privilege reordering ([#4794](#4794))
* engine/direct: Fix 400 error when deploying grants with ALL_PRIVILEGES ([#4801](#4801))
* engine/direct: Fix unwanted recreation of secret scopes when scope_backend_type is not set ([#4834](#4834))
* engine/direct: Fix bind and unbind for non-Terraform resources ([#4850](#4850))
* engine/direct: Fix deploying removed principals ([#4824](#4824))
* engine/direct: Fix secret scope permissions migration from Terraform to Direct engine ([#4866](#4866))
ilia-db added a commit to databricks/databricks-vscode that referenced this pull request Apr 21, 2026
## Summary
Bump bundled Databricks CLI from v0.295.0 → v0.297.2.
## CLI changes since v0.295.0
### v0.297.2 (2026-04-19)
- **Fix `error downloading Terraform: unable to verify checksums
signature: openpgp: key expired`** for `bundle deploy` — uses a
hardcoded ArmoredPublicKey for the TF binary install
([#5019](databricks/cli#5019)). **Highly
relevant** — extension users hitting this during `bundle deploy` flows
are unblocked by the upgrade.
### v0.297.1
- Dep bump only: Go toolchain to 1.25.9.
### v0.297.0
- CLI: `auth` commands accept a profile name as a positional argument
([#4840](databricks/cli#4840)).
- CLI: new `auth logout` command to clear cached OAuth tokens / remove
profiles ([#4613](databricks/cli#4613),
[#4616](databricks/cli#4616),
[#4647](databricks/cli#4647)).
- Bundles: `lifecycle.started` option for apps
([#4672](databricks/cli#4672)).
- Bundles: resource references now resolved correctly in apps config
([#4964](databricks/cli#4964)).
- Bundles: allow `run_as` for dashboards with `embed_credentials: false`
([#4961](databricks/cli#4961)).
- Direct engine: permissions fix for `resources.models`
([#4941](databricks/cli#4941)); update mask fix
for apps ([#4963](databricks/cli#4963)); dotted
map keys fix ([#4977](databricks/cli#4977)).
### v0.296.0
- **Direct deployment engine for DABs is now in Public Preview**
(`docs/direct.md`). Relevant to the extension's bundle deploy UX, though
opt-in.
- CLI: `auth` commands error when `--profile` and `--host` conflict
([#4841](databricks/cli#4841)).
- CLI: `--force-refresh` flag on `databricks auth token`
([#4767](databricks/cli#4767)).
- Bundles: `bundle deployment bind` now pulls remote state before
modifying ([#4892](databricks/cli#4892)).
- Bundles: dedupe grant entries
([#4801](databricks/cli#4801)).
- Direct engine: several fixes (grants reordering, ALL_PRIVILEGES,
secret scope recreation/permissions, bind/unbind for non-TF resources,
removed principals).
## Relevance to the extension
- **TF checksum fix (v0.297.2)** — unblocks `bundle deploy` for users
hitting the expired-key error; this alone is a good reason to ship.
- **Auth CLI surface changes** — extension shells out to `databricks
auth …`; `--profile` + `--host` now conflict, and `auth logout` /
positional profile are new. Worth a glance at auth-related code paths to
make sure we aren't passing both.
- **Direct deploy engine GA preview** — no action required today
(opt-in), but worth tracking for future bundle deploy UX.
## Test plan
- [ ] CI green (unit tests, integration tests pulling the pinned CLI).
- [ ] Manually sanity-check `bundle deploy` from the extension against a
simple bundle to confirm the TF download path works.
- [ ] Verify `databricks auth login` / token refresh flows still work
from the extension.
This pull request and its description were written by Isaac.
denik pushed a commit that referenced this pull request May 20, 2026
## Why
Users can pass both `--profile logfood` and `--host
https://other-host.com` on auth commands with no validation. The CLI
silently picks one based on internal priority, which is confusing.
## Changes
Before: `databricks auth login --profile logfood --host
https://other.com` silently uses one of the two with no warning.
Now: produces an error explaining the conflict and suggesting to use
`--profile` alone.
Adds a `PersistentPreRunE` on the `auth` parent command that validates
when both `--profile` and `--host` are explicitly set. If the profile's
host matches the `--host` value (after canonicalization), the command
proceeds silently. If they conflict, it returns a clear error.
## Test plan
- [x] New unit tests for `validateProfileHostConflict` (5 table-driven
cases: matching hosts, trailing slash, conflict, profile not found, no
host)
- [x] `make checks` passes
- [x] `make lintfull` passes
- [x] `go test ./cmd/auth/` passes
denik pushed a commit that referenced this pull request May 20, 2026
## Release v0.296.0
### Notable Changes
* Direct deployment engine for DABs is now in Public Preview. Documentation at [docs/direct.md](docs/direct.md).
### CLI
* Auth commands now error when --profile and --host conflict ([#4841](#4841))
* Add `--force-refresh` flag to `databricks auth token` to force a token refresh even when the cached token is still valid ([#4767](#4767))
### Bundles
* Deduplicate grant entries with duplicate principals or privileges during initialization ([#4801](#4801))
* Fix `bundle deployment bind` to always pull remote state before modifying ([#4892](#4892))
* engine/direct: Fix drift in grants resource due to privilege reordering ([#4794](#4794))
* engine/direct: Fix 400 error when deploying grants with ALL_PRIVILEGES ([#4801](#4801))
* engine/direct: Fix unwanted recreation of secret scopes when scope_backend_type is not set ([#4834](#4834))
* engine/direct: Fix bind and unbind for non-Terraform resources ([#4850](#4850))
* engine/direct: Fix deploying removed principals ([#4824](#4824))
* engine/direct: Fix secret scope permissions migration from Terraform to Direct engine ([#4866](#4866))
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@simonfaltum@eng-dev-ecosystem-bot@mihaimitrea-db