diff --git a/acceptance/cmd/api/account-flag/script b/acceptance/cmd/api/account-flag/script index de2d4de92b7..b276923914b 100644 --- a/acceptance/cmd/api/account-flag/script +++ b/acceptance/cmd/api/account-flag/script @@ -1,2 +1,2 @@ MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/clusters/list --account -trace print_requests.py --get //api/2.0/clusters/list | contains.py "!X-Databricks-Org-Id" +trace print_requests.py --get //api/2.0/clusters/list | contains.py "!X-Databricks-Workspace-Id" diff --git a/acceptance/cmd/api/account-path/script b/acceptance/cmd/api/account-path/script index 6cc97637695..cb84c2bccf3 100644 --- a/acceptance/cmd/api/account-path/script +++ b/acceptance/cmd/api/account-path/script @@ -1,2 +1,2 @@ MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/accounts/abc-123/network-policies -trace print_requests.py --get //api/2.0/accounts/abc-123/network-policies | contains.py "!X-Databricks-Org-Id" +trace print_requests.py --get //api/2.0/accounts/abc-123/network-policies | contains.py "!X-Databricks-Workspace-Id" diff --git a/acceptance/cmd/api/default-profile/output.txt b/acceptance/cmd/api/default-profile/output.txt index 2d22f0db2bc..882b01befac 100644 --- a/acceptance/cmd/api/default-profile/output.txt +++ b/acceptance/cmd/api/default-profile/output.txt @@ -13,7 +13,7 @@ "User-Agent": [ "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, diff --git a/acceptance/cmd/api/default-profile/script b/acceptance/cmd/api/default-profile/script index 0a926912fa0..44f93db28c7 100644 --- a/acceptance/cmd/api/default-profile/script +++ b/acceptance/cmd/api/default-profile/script @@ -22,7 +22,7 @@ unset DATABRICKS_CONFIG_PROFILE title "default_profile is used when no --profile flag and no DATABRICKS_CONFIG_PROFILE\n" MSYS_NO_PATHCONV=1 trace $CLI api get /api/2.0/clusters/list -trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Org-Id" +trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Workspace-Id" title "--profile overrides default_profile (negative case)\n" MSYS_NO_PATHCONV=1 errcode $CLI api get /api/2.0/clusters/list -p other 2>&1 | contains.py "other.test" diff --git a/acceptance/cmd/api/test.toml b/acceptance/cmd/api/test.toml index 11d83c3f486..d1a9112ed0e 100644 --- a/acceptance/cmd/api/test.toml +++ b/acceptance/cmd/api/test.toml @@ -1,5 +1,5 @@ RecordRequests = true -IncludeRequestHeaders = ["Authorization", "User-Agent", "X-Databricks-Org-Id"] +IncludeRequestHeaders = ["Authorization", "User-Agent", "X-Databricks-Workspace-Id"] # Normalize OS-dependent and CI-only User-Agent segments so the recorded # requests are stable across local macOS/Linux runs and GitHub Actions. diff --git a/acceptance/cmd/api/workspace-id-flag/output.txt b/acceptance/cmd/api/workspace-id-flag/output.txt index 5ff264fa554..2ed9f181211 100644 --- a/acceptance/cmd/api/workspace-id-flag/output.txt +++ b/acceptance/cmd/api/workspace-id-flag/output.txt @@ -9,7 +9,7 @@ "User-Agent": [ "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "999" ] }, diff --git a/acceptance/cmd/api/workspace-id-flag/script b/acceptance/cmd/api/workspace-id-flag/script index 83664ba8662..060a6fafbcb 100644 --- a/acceptance/cmd/api/workspace-id-flag/script +++ b/acceptance/cmd/api/workspace-id-flag/script @@ -1,2 +1,2 @@ MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/clusters/list --workspace-id 999 -trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Org-Id" "999" +trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Workspace-Id" "999" diff --git a/acceptance/cmd/api/workspace-id-from-query/output.txt b/acceptance/cmd/api/workspace-id-from-query/output.txt index 7a72f8de473..f62e2c45f57 100644 --- a/acceptance/cmd/api/workspace-id-from-query/output.txt +++ b/acceptance/cmd/api/workspace-id-from-query/output.txt @@ -9,7 +9,7 @@ "User-Agent": [ "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "999" ] }, diff --git a/acceptance/cmd/api/workspace-id-from-query/script b/acceptance/cmd/api/workspace-id-from-query/script index fd3fa0e151b..ff74526bf88 100644 --- a/acceptance/cmd/api/workspace-id-from-query/script +++ b/acceptance/cmd/api/workspace-id-from-query/script @@ -1,2 +1,2 @@ MSYS_NO_PATHCONV=1 $CLI api get "/api/2.0/clusters/list?o=999" -trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Org-Id" "999" +trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Workspace-Id" "999" diff --git a/acceptance/cmd/api/workspace-id-none/script b/acceptance/cmd/api/workspace-id-none/script index 4ecd00c6768..9e01e4da2d4 100644 --- a/acceptance/cmd/api/workspace-id-none/script +++ b/acceptance/cmd/api/workspace-id-none/script @@ -10,4 +10,4 @@ workspace_id = none EOF MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/clusters/list --profile spog-account -trace print_requests.py --get //api/2.0/clusters/list | contains.py "!X-Databricks-Org-Id" +trace print_requests.py --get //api/2.0/clusters/list | contains.py "!X-Databricks-Workspace-Id" diff --git a/acceptance/cmd/api/workspace-path/output.txt b/acceptance/cmd/api/workspace-path/output.txt index 9d17f66284f..e4685830e47 100644 --- a/acceptance/cmd/api/workspace-path/output.txt +++ b/acceptance/cmd/api/workspace-path/output.txt @@ -9,7 +9,7 @@ "User-Agent": [ "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, diff --git a/acceptance/cmd/api/workspace-path/script b/acceptance/cmd/api/workspace-path/script index 4e5bb35c4be..16351c0ef07 100644 --- a/acceptance/cmd/api/workspace-path/script +++ b/acceptance/cmd/api/workspace-path/script @@ -1,2 +1,2 @@ MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/clusters/list -trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Org-Id" +trace print_requests.py --get //api/2.0/clusters/list | contains.py "X-Databricks-Workspace-Id" diff --git a/acceptance/cmd/api/workspace-proxy-regression/output.txt b/acceptance/cmd/api/workspace-proxy-regression/output.txt index c98486a15e1..66cbd75022a 100644 --- a/acceptance/cmd/api/workspace-proxy-regression/output.txt +++ b/acceptance/cmd/api/workspace-proxy-regression/output.txt @@ -9,7 +9,7 @@ "User-Agent": [ "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/api_get cmd-exec-id/[UUID] interactive/none auth/pat" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, diff --git a/acceptance/cmd/api/workspace-proxy-regression/script b/acceptance/cmd/api/workspace-proxy-regression/script index 39ab661f4f1..8620765476d 100644 --- a/acceptance/cmd/api/workspace-proxy-regression/script +++ b/acceptance/cmd/api/workspace-proxy-regression/script @@ -2,4 +2,4 @@ # being misclassified as account-scope, so the routing identifier should be # present on the recorded request. MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/preview/accounts/access-control/rule-sets -trace print_requests.py --get //api/2.0/preview/accounts/access-control/rule-sets | contains.py "X-Databricks-Org-Id" +trace print_requests.py --get //api/2.0/preview/accounts/access-control/rule-sets | contains.py "X-Databricks-Workspace-Id" diff --git a/acceptance/telemetry/failure/out.requests.txt b/acceptance/telemetry/failure/out.requests.txt index 808b5e97243..11c7bffe1ce 100644 --- a/acceptance/telemetry/failure/out.requests.txt +++ b/acceptance/telemetry/failure/out.requests.txt @@ -7,7 +7,7 @@ "Authorization": [ "Bearer [DATABRICKS_TOKEN]" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, @@ -27,7 +27,7 @@ "Authorization": [ "Bearer [DATABRICKS_TOKEN]" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, @@ -47,7 +47,7 @@ "Authorization": [ "Bearer [DATABRICKS_TOKEN]" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, diff --git a/acceptance/telemetry/partial-success/out.requests.txt b/acceptance/telemetry/partial-success/out.requests.txt index 808b5e97243..11c7bffe1ce 100644 --- a/acceptance/telemetry/partial-success/out.requests.txt +++ b/acceptance/telemetry/partial-success/out.requests.txt @@ -7,7 +7,7 @@ "Authorization": [ "Bearer [DATABRICKS_TOKEN]" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, @@ -27,7 +27,7 @@ "Authorization": [ "Bearer [DATABRICKS_TOKEN]" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, @@ -47,7 +47,7 @@ "Authorization": [ "Bearer [DATABRICKS_TOKEN]" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, diff --git a/acceptance/telemetry/success/out.requests.txt b/acceptance/telemetry/success/out.requests.txt index f73cd0a891e..01267fa3a72 100644 --- a/acceptance/telemetry/success/out.requests.txt +++ b/acceptance/telemetry/success/out.requests.txt @@ -15,7 +15,7 @@ "User-Agent": [ "cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/selftest_send-telemetry cmd-exec-id/[CMD-EXEC-ID] interactive/none auth/pat" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, diff --git a/acceptance/telemetry/test.toml b/acceptance/telemetry/test.toml index cce01f8ccd2..f6f033b91ee 100644 --- a/acceptance/telemetry/test.toml +++ b/acceptance/telemetry/test.toml @@ -1,4 +1,4 @@ -IncludeRequestHeaders = ["Authorization", "X-Databricks-Org-Id"] +IncludeRequestHeaders = ["Authorization", "X-Databricks-Workspace-Id"] RecordRequests = true Local = true diff --git a/acceptance/telemetry/timeout/out.requests.txt b/acceptance/telemetry/timeout/out.requests.txt index 1241a933a9a..89556e1dcb7 100644 --- a/acceptance/telemetry/timeout/out.requests.txt +++ b/acceptance/telemetry/timeout/out.requests.txt @@ -7,7 +7,7 @@ "Authorization": [ "Bearer [DATABRICKS_TOKEN]" ], - "X-Databricks-Org-Id": [ + "X-Databricks-Workspace-Id": [ "[NUMID]" ] }, diff --git a/bundle/deploy/filer.go b/bundle/deploy/filer.go index a6b36f8d04e..e773df4e0e0 100644 --- a/bundle/deploy/filer.go +++ b/bundle/deploy/filer.go @@ -25,16 +25,16 @@ type stateFiler struct { root filer.WorkspaceRootPath } -// orgIDHeaders returns headers with X-Databricks-Org-Id set if a workspace ID -// is configured. SPOG hosts require this header to route requests to the -// correct workspace. -func (s stateFiler) orgIDHeaders() map[string]string { +// workspaceIDHeaders returns headers with X-Databricks-Workspace-Id set if a +// workspace ID is configured. SPOG hosts require this header to route requests +// to the correct workspace. +func (s stateFiler) workspaceIDHeaders() map[string]string { wsID := s.apiClient.Config.WorkspaceID if wsID == "" { return nil } return map[string]string{ - "X-Databricks-Org-Id": wsID, + "X-Databricks-Workspace-Id": wsID, } } @@ -63,7 +63,7 @@ func (s stateFiler) Read(ctx context.Context, path string) (io.ReadCloser, error var buf bytes.Buffer urlPath := "/api/2.0/workspace-files/" + url.PathEscape(strings.TrimLeft(absPath, "/")) - err = s.apiClient.Do(ctx, http.MethodGet, urlPath, s.orgIDHeaders(), nil, nil, &buf) + err = s.apiClient.Do(ctx, http.MethodGet, urlPath, s.workspaceIDHeaders(), nil, nil, &buf) if err != nil { return nil, err } diff --git a/cmd/api/api.go b/cmd/api/api.go index a832f018c1a..044584c1220 100644 --- a/cmd/api/api.go +++ b/cmd/api/api.go @@ -20,10 +20,12 @@ import ( ) const ( - // orgIDHeader is the workspace routing identifier sent on workspace-scope - // requests against unified hosts. Generated SDK service methods set this - // per-call when cfg.WorkspaceID is populated; we mirror the same idiom. - orgIDHeader = "X-Databricks-Org-Id" + // workspaceIDHeader is the workspace routing identifier sent on + // workspace-scope requests against unified hosts. Generated SDK service + // methods set this per-call when cfg.WorkspaceID is populated; we mirror + // the same idiom. The gateway also accepts the legacy X-Databricks-Org-Id + // header for rollback safety. + workspaceIDHeader = "X-Databricks-Workspace-Id" // orgIDQueryParam is the SPOG (single-page-of-glass) URL convention used // by the Databricks UI: "?o=" identifies the workspace a URL @@ -114,7 +116,7 @@ func makeCommand(method string) *cobra.Command { headers := map[string]string{"Content-Type": "application/json"} if orgID != "" { - headers[orgIDHeader] = orgID + headers[workspaceIDHeader] = orgID } var response any diff --git a/libs/filer/files_client.go b/libs/filer/files_client.go index 6abfa1e66c3..b09d10de7af 100644 --- a/libs/filer/files_client.go +++ b/libs/filer/files_client.go @@ -109,16 +109,16 @@ func NewFilesClient(w *databricks.WorkspaceClient, root string) (Filer, error) { }, nil } -// orgIDHeaders returns headers with X-Databricks-Org-Id set if a workspace ID -// is configured. SPOG hosts require this header to route requests to the -// correct workspace. -func (w *FilesClient) orgIDHeaders() map[string]string { +// workspaceIDHeaders returns headers with X-Databricks-Workspace-Id set if a +// workspace ID is configured. SPOG hosts require this header to route requests +// to the correct workspace. +func (w *FilesClient) workspaceIDHeaders() map[string]string { wsID := w.workspaceClient.Config.WorkspaceID if wsID == "" { return nil } return map[string]string{ - "X-Databricks-Org-Id": wsID, + "X-Databricks-Workspace-Id": wsID, } } @@ -162,7 +162,7 @@ func (w *FilesClient) Write(ctx context.Context, name string, reader io.Reader, urlPath = fmt.Sprintf("%s?overwrite=%t", urlPath, overwrite) headers := map[string]string{"Content-Type": "application/octet-stream"} if wsID := w.workspaceClient.Config.WorkspaceID; wsID != "" { - headers["X-Databricks-Org-Id"] = wsID + headers["X-Databricks-Workspace-Id"] = wsID } err = w.apiClient.Do(ctx, http.MethodPut, urlPath, headers, nil, reader, nil) @@ -192,7 +192,7 @@ func (w *FilesClient) Read(ctx context.Context, name string) (io.ReadCloser, err } var reader io.ReadCloser - err = w.apiClient.Do(ctx, http.MethodGet, urlPath, w.orgIDHeaders(), nil, nil, &reader) + err = w.apiClient.Do(ctx, http.MethodGet, urlPath, w.workspaceIDHeaders(), nil, nil, &reader) // Return early on success. if err == nil { diff --git a/libs/filer/workspace_files_client.go b/libs/filer/workspace_files_client.go index 3663473e92a..d49b10b8ace 100644 --- a/libs/filer/workspace_files_client.go +++ b/libs/filer/workspace_files_client.go @@ -121,10 +121,10 @@ type WorkspaceFilesClient struct { root WorkspaceRootPath } -// orgIDHeaders returns headers with X-Databricks-Org-Id set if a workspace ID -// is configured. SPOG hosts require this header to route requests to the -// correct workspace. -func (w *WorkspaceFilesClient) orgIDHeaders() map[string]string { +// workspaceIDHeaders returns headers with X-Databricks-Workspace-Id set if a +// workspace ID is configured. SPOG hosts require this header to route requests +// to the correct workspace. +func (w *WorkspaceFilesClient) workspaceIDHeaders() map[string]string { if w.workspaceClient == nil || w.workspaceClient.Config == nil { return nil } @@ -133,7 +133,7 @@ func (w *WorkspaceFilesClient) orgIDHeaders() map[string]string { return nil } return map[string]string{ - "X-Databricks-Org-Id": wsID, + "X-Databricks-Workspace-Id": wsID, } } @@ -171,7 +171,7 @@ func (w *WorkspaceFilesClient) Write(ctx context.Context, name string, reader io return err } - err = w.apiClient.Do(ctx, http.MethodPost, urlPath, w.orgIDHeaders(), nil, body, nil) + err = w.apiClient.Do(ctx, http.MethodPost, urlPath, w.workspaceIDHeaders(), nil, body, nil) // Return early on success. if err == nil { @@ -349,7 +349,7 @@ func (w *WorkspaceFilesClient) Stat(ctx context.Context, name string) (fs.FileIn ctx, http.MethodGet, "/api/2.0/workspace/get-status", - w.orgIDHeaders(), + w.workspaceIDHeaders(), nil, map[string]string{ "path": absPath, diff --git a/libs/filer/workspace_files_client_test.go b/libs/filer/workspace_files_client_test.go index e7b5a337a7f..2915af60436 100644 --- a/libs/filer/workspace_files_client_test.go +++ b/libs/filer/workspace_files_client_test.go @@ -61,7 +61,7 @@ func TestWorkspaceFilesDirEntry(t *testing.T) { assert.True(t, i2.IsDir()) } -func TestWorkspaceFilesClientOrgIDHeaders(t *testing.T) { +func TestWorkspaceFilesClientWorkspaceIDHeaders(t *testing.T) { tests := []struct { name string workspaceID string @@ -70,7 +70,7 @@ func TestWorkspaceFilesClientOrgIDHeaders(t *testing.T) { { name: "with workspace ID", workspaceID: "7474644166319138", - expect: map[string]string{"X-Databricks-Org-Id": "7474644166319138"}, + expect: map[string]string{"X-Databricks-Workspace-Id": "7474644166319138"}, }, { name: "without workspace ID", @@ -87,13 +87,13 @@ func TestWorkspaceFilesClientOrgIDHeaders(t *testing.T) { }, }, } - assert.Equal(t, tc.expect, w.orgIDHeaders()) + assert.Equal(t, tc.expect, w.workspaceIDHeaders()) }) } t.Run("nil workspace client", func(t *testing.T) { w := &WorkspaceFilesClient{} - assert.Nil(t, w.orgIDHeaders()) + assert.Nil(t, w.workspaceIDHeaders()) }) } diff --git a/libs/telemetry/logger.go b/libs/telemetry/logger.go index f9df3a97f7b..7cda184bd04 100644 --- a/libs/telemetry/logger.go +++ b/libs/telemetry/logger.go @@ -170,23 +170,23 @@ func Upload(ctx context.Context, ec protos.ExecutionContext) error { return errors.New("failed to upload telemetry logs after three attempts") } -// orgIDHeaders returns headers with X-Databricks-Org-Id set if a workspace ID -// is configured. SPOG hosts require this header to route requests to the -// correct workspace; without it, telemetry is recorded in a central shard -// instead of the correct workspace. -func orgIDHeaders(apiClient *client.DatabricksClient) map[string]string { +// workspaceIDHeaders returns headers with X-Databricks-Workspace-Id set if a +// workspace ID is configured. SPOG hosts require this header to route requests +// to the correct workspace; without it, telemetry is recorded in a central +// shard instead of the correct workspace. +func workspaceIDHeaders(apiClient *client.DatabricksClient) map[string]string { wsID := apiClient.Config.WorkspaceID if wsID == "" { return nil } return map[string]string{ - "X-Databricks-Org-Id": wsID, + "X-Databricks-Workspace-Id": wsID, } } func attempt(ctx context.Context, apiClient *client.DatabricksClient, protoLogs []string) (*ResponseBody, error) { resp := &ResponseBody{} - err := apiClient.Do(ctx, http.MethodPost, "/telemetry-ext", orgIDHeaders(apiClient), nil, RequestBody{ + err := apiClient.Do(ctx, http.MethodPost, "/telemetry-ext", workspaceIDHeaders(apiClient), nil, RequestBody{ UploadTime: time.Now().UnixMilli(), // There is a bug in the `/telemetry-ext` API which requires us to // send an empty array for the `Items` field. Otherwise the API returns