DATABRICKS_HOST env variable is ignored when using CLI inside DAB directory
Maintainer thường phản hồi trong vòng 1 ngày
@simonfaltum đang làm issue này rồi.
Từ ngày 23/2/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Describe the issue
When executing non-bundle commands (e.g., databricks current-user me) from within a directory containing a Databricks Asset Bundle (databricks.yml file exists), the CLI uses the bundle's default target of databricks.yml file over the explicitly defined DATABRICKS_HOST environment variable. That should never be used as we are running a non-bundle command.
Behavior:
- Non-DAB commands inside DAB folder: The CLI ignores
DATABRICKS_HOSTand attempts to connect to the default target defined indatabricks.yml. - Non-DAB commands outside DAB folder: The CLI correctly uses
DATABRICKS_HOST. - DAB commands: Correctly respects
DATABRICKS_HOSTdefined.
Steps to reproduce the behavior
- Create a databricks.yml file in the current directory with a dev target set as default:
targets:
dev:
mode: development
default: true
workspace:
host: https://dev-environment.cloud.databricks.com
stg:
mode: production
workspace:
host: https://stg-environment.cloud.databricks.com
- Set environment variables to point to a different environment (Staging):
export DATABRICKS_HOST=https://stg-environment.cloud.databricks.com
export DATABRICKS_TOKEN=dapi_stg_token_here
- Execute a non-bundle command with debug logging in DAB folder (where
databricks.ymlfile exists):
databricks current-user me --debug
Expected Behavior
The CLI should use the environment variable DATABRICKS_HOST. The command should execute against the Staging environment.
Actual Behavior
The CLI detects the bundle, loads the dev target because it is marked as default: true, and attempts to authenticate against the Dev environment, resulting in an Invalid Token error (as the token provided is for Staging).
OS and CLI version
- OS: Linux (Docker python:3.11-alpine)
- Databricks CLI Version: v0.288.0
Is this a regression?
Unknown, but consistently reproducible since at least v0.283.0.
Debug Logs
The logs clearly show the SelectDefaultTarget mutator forcing the target to dev despite the environment variables:
$ cd databricks
$ databricks current-user me --debug
15:35:06 Info: start pid=44 version=0.288.0 args="databricks, current-user, me, --debug"
15:35:06 Debug: Found bundle root at /my_repo_root/databricks (file /my_repo_root/databricks/databricks.yml) pid=44
15:35:06 Info: Phase: load pid=44
15:35:06 Debug: Apply pid=44 mutator=EntryPoint
15:35:06 Debug: Apply pid=44 mutator=scripts.preinit
15:35:06 Debug: No script defined for preinit, skipping pid=44 mutator=scripts.preinit
15:35:06 Debug: Apply pid=44 mutator=ProcessRootIncludes
15:35:06 Debug: Apply pid=44 mutator=ProcessRootIncludes mutator=ProcessInclude(resources/my_job_a.job.yml)
15:35:06 Debug: Apply pid=44 mutator=ProcessRootIncludes mutator=ProcessInclude(resources/my_job_b.job.yml)
15:35:06 Debug: Apply pid=44 mutator=VerifyCliVersion
15:35:06 Debug: Apply pid=44 mutator=EnvironmentsToTargets
15:35:06 Debug: Apply pid=44 mutator=ComputeIdToClusterId
15:35:06 Debug: Apply pid=44 mutator=InitializeVariables
15:35:06 Debug: Apply pid=44 mutator=DefineDefaultTarget(default)
15:35:06 Debug: Apply pid=44 mutator=validate:unique_resource_keys
15:35:06 Debug: Apply pid=44 mutator=SelectDefaultTarget
15:35:06 Debug: Apply pid=44 mutator=SelectDefaultTarget mutator=SelectTarget(dev)
15:35:06 Debug: GET /api/2.0/preview/scim/v2/Me
< HTTP/2.0 400 Bad Request
< Invalid Token pid=44 sdk=true
15:35:06 Debug: non-retriable error: Invalid Token pid=44 sdk=true
Error: Invalid Token
15:35:06 Info: failed execution pid=44 exit_code=1 error="Invalid Token"
15:35:06 Debug: no telemetry logs to upload pid=44
- Ngôn ngữ chính
- Go
- Star
- 396
- Fork
- 233
- Merge trung bình
- 2 ngày 52 phút
- Pull request đã merge (30 ngày)
- 276
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của databricks/cli
-
DABs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
databricks/cli#6670 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DABs PyDABs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
databricks/cli#3926 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
databricks/cli#6786 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
databricks/cli#6785 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
databricks/cli#6770 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của databricks/cli
Issue tương tự
-
bug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
netdata/netdata#24062 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
meshery/meshery#22119 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
automation documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] 安装向导生成了两个 rate_limit 无效参数Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày