fix: avoid implicit bundle target for non-bundle auth resolution#4504
fix: avoid implicit bundle target for non-bundle auth resolution#4504jmahotiedu wants to merge 2 commits intodatabricks:mainfrom
Conversation
|
I just recently had a 1 hour troubleshooting session trying to figure out why an Azure SP could not login to a test environment when it worked in dev in my Github Workflow, when I finally realized it was not actually logging into test, but following the bundle's default environment. In my case I have a utility workflow script (running in a folder that also has DAB) that is doing non-bundle related items with CLI that was relying on my workflow's DATABRICKS_HOST env var. |
|
Thanks @NateWerner, this is exactly the real-world failure mode this PR is intended to fix. With this change, bundle auth is only used when @andrewnester if you have bandwidth, could you please approve workflow execution for #4504 so required checks can run? Happy to make any follow-up changes. |
|
We had an internal discussion about this and we would like to keep auth resolved based on bundle configuration but we want to make any explicit configurations (--profile flag or env vvariables suich as DATABRICKS_HOST) take the precedence. This would solve the issue in #4502 The reason being is if someone uses non-bundle command, for example, cc @simonfaltum |
|
Thanks for the clarification @andrewnester. I agree with this direction and updated the PR to match it. Implemented in
So for
I also expanded tests to cover this precedence matrix (including Happy to adjust further if you want any precedence edge cases handled differently. |
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
## Summary
Stop loading bundle auth configuration implicitly in
MustWorkspaceClientunless--target/--environmentis explicitly set.Keep explicit target behavior unchanged so bundle context remains opt-in.
Add regression tests covering:
DATABRICKS_HOST.--targetstill uses bundle target host.## Problem
Fixes #4502. Non-bundle commands such as
databricks current-user mewere resolving authentication from the bundle’s default target when run inside a bundle directory, potentially overridingDATABRICKS_HOST.## Testing
go test ./cmd/root