Skip to content

Use X-Databricks-Workspace-Id for workspace routing#1688

Open
Divyansh-db wants to merge 2 commits into
mainfrom
divyansh-vijayvergia_data/new-workspace-parameter
Open

Use X-Databricks-Workspace-Id for workspace routing#1688
Divyansh-db wants to merge 2 commits into
mainfrom
divyansh-vijayvergia_data/new-workspace-parameter

Conversation

@Divyansh-db
Copy link
Copy Markdown
Contributor

@Divyansh-db Divyansh-db commented May 19, 2026

Summary

Workspace-scoped API calls now identify the target workspace via the X-Databricks-Workspace-Id header instead of X-Databricks-Org-Id. The value source is unchanged: it still comes from Config.WorkspaceID (or the DATABRICKS_WORKSPACE_ID environment variable).

Why

On unified Databricks hosts that serve multiple workspaces, the SDK sends a routing header on every workspace-scoped HTTP request so the gateway can dispatch it to the correct workspace. Until now that header was X-Databricks-Org-Id.

The Databricks platform is consolidating workspace addressing onto a single header, X-Databricks-Workspace-Id, which accepts a broader range of workspace identifier formats and replaces the older single-purpose channels going forward. The previous header continues to be accepted by the platform, so older SDK versions keep working, but new SDK versions should use the new name.

This PR is the Go SDK's part of that migration.

What changed

Interface changes

None. Config.WorkspaceID keeps the same field name, type (string), and environment variable (DATABRICKS_WORKSPACE_ID). The doc comment is widened to note that the value may now be either a classic numeric workspace ID or another workspace identifier format that the server understands.

Behavioral changes

  • Workspace-scoped requests no longer send X-Databricks-Org-Id. They now send X-Databricks-Workspace-Id (with the same value, gated on Config.WorkspaceID being non-empty). Account-scoped requests are unaffected.
  • WorkspaceClient.CurrentWorkspaceID reads the workspace ID from the X-Databricks-Workspace-Id response header on /api/2.0/preview/scim/v2/Me instead of X-Databricks-Org-Id.

Internal changes

  • Regenerated service/*/impl.go and internal/testspecs/service/*/impl.go from the corresponding generator template change: 34 files, 944 line swaps, no logic change.
  • Updated the hand-written sites that emit the same header on workspace-scoped calls but are not covered by the generator: service/iam/ext_impl.go, service/sharing/ext_api.go, service/workspace/ext_utilities.go, and workspace_functions.go.
  • Renamed the two TestCurrentWorkspaceID* test functions so the names match the new header.

How is this tested?

  • make fmt, make lint, and make test all pass locally. Full unit suite is green (1404 passed, 103 skipped).
  • The two workspace_functions_test.go tests cover both sides of the new header (request emission and response parsing on the Me probe).
  • Spot-checked the regenerated diff: every changed line in service/*/impl.go is exclusively the header literal swap; no collateral changes.

Regenerated from the gosdkv0 template change in
databricks-eng/universe#1955306, which renames the workspace routing header
emitted on SPOG/unified-host requests from `X-Databricks-Org-Id` to
`X-Databricks-Workspace-Id`. This is the M1 piece of the "DECO + Unified
Workspace Addressing" initiative.

The diff is mechanical: 944 swaps across 34 generated files, no behavioral
change. The value still comes from `Config.WorkspaceID` and emission is still
gated on the operation being workspace-scoped (`!Service.IsAccounts`).

Co-authored-by: Isaac
Signed-off-by: Divyansh Vijayvergia <divyansh.vijayvergia@databricks.com>
Companion to the regenerated code: the generator only touched the OpenAPI-spec
backed `service/*/impl.go` files. This change updates the hand-written sites
that emit or parse the same SPOG routing header on workspace-scoped API calls:

- `service/iam/ext_impl.go`, `service/sharing/ext_api.go`,
  `service/workspace/ext_utilities.go`: swap `X-Databricks-Org-Id` →
  `X-Databricks-Workspace-Id` in the manually-written header injection (these
  files extend generated services with hand-written endpoints/wrappers and
  weren't covered by the codegen pass).
- `workspace_functions.go`: `CurrentWorkspaceID` now sends and reads the new
  header on `/api/2.0/preview/scim/v2/Me`; doc comments updated.
- `workspace_functions_test.go`: tests assert the new header name; function
  names renamed (`OrgIdHeader` → `WorkspaceIdHeader`) so the test names
  reflect what they cover.
- `config/config.go`: widen the `WorkspaceID` doc comment to note the value
  can now be a classic numeric workspace ID *or* a CPDR connection ID (the
  server disambiguates). Field name, type, and env var (`DATABRICKS_WORKSPACE_ID`)
  unchanged.
- `NEXT_CHANGELOG.md`: entry under Internal Changes.

POPP keeps accepting the legacy `X-Databricks-Org-Id` for rollback safety, so
this is safe to land any time after M0 platform support is fully rolled out.

Co-authored-by: Isaac
Signed-off-by: Divyansh Vijayvergia <divyansh.vijayvergia@databricks.com>
@Divyansh-db Divyansh-db temporarily deployed to test-trigger-is May 19, 2026 12:51 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-go

Inputs:

  • PR number: 1688
  • Commit SHA: 6fe3278eed5a6cc36654baf1867b712fa880ff98

Checks will be approved automatically on success.

@Divyansh-db Divyansh-db temporarily deployed to test-trigger-is May 19, 2026 12:52 — with GitHub Actions Inactive
@Divyansh-db Divyansh-db temporarily deployed to test-trigger-is May 19, 2026 12:53 — with GitHub Actions Inactive
@Divyansh-db Divyansh-db changed the title Divyansh vijayvergia data/new workspace parameter Use X-Databricks-Workspace-Id for workspace routing May 19, 2026
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.

1 participant