Skip to content

Commit 2cb9ab4

Browse files
authored
Send X-Databricks-Workspace-Id on workspace-routed API calls (databricks#5368)
## Summary On unified Databricks hosts that serve multiple workspaces, the CLI sends a routing header so the gateway can dispatch each request to the correct workspace. The platform is consolidating workspace addressing onto a single header name. This PR switches the header sent on workspace-scoped API calls from `X-Databricks-Org-Id` to `X-Databricks-Workspace-Id`. The previous header continues to be accepted by the platform, so older CLI versions keep working. The value continues to come from the `workspace_id` config field or `DATABRICKS_WORKSPACE_ID` environment variable. ## Scope Hand-written CLI paths that issue workspace-routed API calls without going through generated SDK service methods: - `databricks api {verb}` (`cmd/api/api.go`) - Files API filer (`libs/filer/files_client.go`) - Workspace files filer (`libs/filer/workspace_files_client.go`) - Telemetry uploads (`libs/telemetry/logger.go`) The matching change inside the SDK landed in databricks/databricks-sdk-go#1688 and will reach generated service methods on the next SDK bump. ## Asymmetric migration Only the *request*-side header flips. The SDK's `CurrentWorkspaceID()` still reads `X-Databricks-Org-Id` from the response on `/api/2.0/preview/scim/v2/Me`, because the server continues to echo the legacy response header. The two CLI test fakes that support that flow stay on the legacy name intentionally: - `libs/testserver/handlers.go` — `/Me` mock response header - `libs/testproxy/server.go` — `includeResponseHeaders` for the proxy ## Test plan - [x] `go test ./cmd/api/... ./libs/filer/... ./libs/telemetry/...` — green - [x] `go test ./acceptance -run 'TestAccept/cmd/api|TestAccept/telemetry/(failure|timeout|partial)'` — green (acceptance fixtures regenerated via `-update`) - [x] `./task lint-q` — 0 issues; `./task fmt` — no changes - [x] `git grep -in 'X-Databricks-Org' -- ':!*.md' ':!*.sum' ':!bundle/'` — only the two intentional response-side fakes plus a context comment in `cmd/api/api.go`
1 parent cf28cd2 commit 2cb9ab4

32 files changed

Lines changed: 186 additions & 84 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/clusters/list --account
2-
trace print_requests.py --get //api/2.0/clusters/list | contains.py "!X-Databricks-Org-Id"
2+
trace print_requests.py --get //api/2.0/clusters/list | contains.py "!X-Databricks-Workspace-Id"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/accounts/abc-123/network-policies
2-
trace print_requests.py --get //api/2.0/accounts/abc-123/network-policies | contains.py "!X-Databricks-Org-Id"
2+
trace print_requests.py --get //api/2.0/accounts/abc-123/network-policies | contains.py "!X-Databricks-Workspace-Id"

acceptance/cmd/api/default-profile/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"User-Agent": [
1414
"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat"
1515
],
16-
"X-Databricks-Org-Id": [
16+
"X-Databricks-Workspace-Id": [
1717
"[NUMID]"
1818
]
1919
},

acceptance/cmd/api/default-profile/script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ unset DATABRICKS_CONFIG_PROFILE
2222

2323
title "default_profile is used when no --profile flag and no DATABRICKS_CONFIG_PROFILE\n"
2424
MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/clusters/list
25-
trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Org-Id"
25+
trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Workspace-Id"
2626

2727
title "--profile overrides default_profile (negative case)\n"
2828
MSYS_NO_PATHCONV=1 errcode $CLI api get /api/2.0/clusters/list -p other 2>&1 | contains.py "other.test"

acceptance/cmd/api/test.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
RecordRequests = true
2-
IncludeRequestHeaders = ["Authorization", "User-Agent", "X-Databricks-Org-Id"]
2+
IncludeRequestHeaders = ["Authorization", "User-Agent", "X-Databricks-Workspace-Id"]
33

44
# Normalize OS-dependent and CI-only User-Agent segments so the recorded
55
# requests are stable across local macOS/Linux runs and GitHub Actions.

acceptance/cmd/api/workspace-id-flag/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"User-Agent": [
1010
"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat"
1111
],
12-
"X-Databricks-Org-Id": [
12+
"X-Databricks-Workspace-Id": [
1313
"999"
1414
]
1515
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/clusters/list --workspace-id 999
2-
trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Org-Id" "999"
2+
trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Workspace-Id" "999"

acceptance/cmd/api/workspace-id-from-query/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"User-Agent": [
1010
"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat"
1111
],
12-
"X-Databricks-Org-Id": [
12+
"X-Databricks-Workspace-Id": [
1313
"999"
1414
]
1515
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
MSYS_NO_PATHCONV=1 $CLI api get "/api/2.0/clusters/list?o=999"
2-
trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Org-Id" "999"
2+
trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Workspace-Id" "999"

acceptance/cmd/api/workspace-id-from-w-query/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)