Skip to content

fix: avoid implicit bundle target for non-bundle auth resolution#4504

Open
jmahotiedu wants to merge 1 commit intodatabricks:mainfrom
jmahotiedu:fix/non-bundle-ignore-bundle-auth-4502
Open

fix: avoid implicit bundle target for non-bundle auth resolution#4504
jmahotiedu wants to merge 1 commit intodatabricks:mainfrom
jmahotiedu:fix/non-bundle-ignore-bundle-auth-4502

Conversation

@jmahotiedu
Copy link

@jmahotiedu jmahotiedu commented Feb 12, 2026

## Summary

  • Stop loading bundle auth configuration implicitly in MustWorkspaceClient unless --target / --environment is explicitly set.

  • Keep explicit target behavior unchanged so bundle context remains opt-in.

  • Add regression tests covering:

    • Non-bundle command inside bundle directory respects DATABRICKS_HOST.
    • Explicit --target still uses bundle target host.

## Problem
Fixes #4502. Non-bundle commands such as databricks current-user me were resolving authentication from the bundle’s default target when run inside a bundle directory, potentially overriding DATABRICKS_HOST.

## Testing

  • go test ./cmd/root

@github-actions
Copy link

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 4504
  • Commit SHA: db5cb1821e7e05c06d87783b389b90a59f630f67

Checks will be approved automatically on success.

@NateWerner
Copy link

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.
Feels odd to spray "-t " all over my non-bundle Databricks utility script.
Thanks for proposing this change.

@jmahotiedu
Copy link
Author

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 --target / --environment is explicitly provided. For non-bundle commands, even inside a DAB directory, auth resolution respects DATABRICKS_HOST; explicit -t behavior remains unchanged.

@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.

Sign up for free to 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.

DATABRICKS_HOST env variable is ignored when using CLI inside DAB directory

2 participants

Comments