Commit 0a030bd
authored
Use X-Databricks-Workspace-Id for workspace routing (#1688)
## Summary
Workspace-scoped API calls now identify the target workspace via the
`X-Databricks-Workspace-Id` request 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). The response-side header read in `CurrentWorkspaceID` is left
on the legacy name for now. A new `CurrentWorkspaceIdentifier` helper is
added to support workspace identifier formats other than classic numeric
IDs.
## 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 on the **request** side.
The platform's response-side echo header has not yet been renamed, so
the SDK continues to read the workspace ID back from the legacy
`X-Databricks-Org-Id` response header.
## What changed
### Interface changes
- **New**: `WorkspaceClient.CurrentWorkspaceIdentifier(ctx
context.Context) (string, error)` — returns the workspace identifier
exactly as the server echoes it back, without attempting to parse it as
a number. Use this in preference to `CurrentWorkspaceID` if your code
may run against workspaces whose identifier is not a classic numeric ID.
- `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.
- `CurrentWorkspaceID(ctx) (int64, error)` is unchanged signature-wise
but is now a thin `ParseInt` adapter over `CurrentWorkspaceIdentifier`.
Existing callers keep working byte-for-byte against classic numeric
workspaces; for non-numeric identifiers it returns the parse error from
`strconv.ParseInt`.
### 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` and the new
`CurrentWorkspaceIdentifier` send `X-Databricks-Workspace-Id` as the
routing header and read the workspace ID back from the legacy
`X-Databricks-Org-Id` response header on `/api/2.0/preview/scim/v2/Me` —
the server still emits the legacy name on responses, and the
response-side migration is on a separate, later schedule.
### 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`.
- Manually patched 16 occurrences in newly-merged generated code
(`service/bundle/impl.go`, `service/dashboards/impl.go:733`,
`service/postgres/impl.go:625`) that came in via an auto-codegen update
made before the generator template change was available. This will be a
no-op against the next regen after the generator change lands upstream.
- Renamed the two `TestCurrentWorkspaceID*` test functions so the names
match the new header on the request side.
## How is this tested?
- `make fmt`, `make lint`, and `make test` all pass locally. Full unit
suite is green.
- The four `workspace_functions_test.go` tests cover both helpers: they
assert the new `X-Databricks-Workspace-Id` request header is sent, that
the SDK reads the workspace ID back from the legacy
`X-Databricks-Org-Id` response header, and that
`CurrentWorkspaceIdentifier` returns non-numeric identifiers verbatim
while `CurrentWorkspaceID` returns a parse error for those.
- Spot-checked the regenerated diff: every changed line in
`service/*/impl.go` is exclusively the request-header literal swap; no
collateral changes.
- End-to-end verified against a staging workspace: the SDK sends
`X-Databricks-Workspace-Id` correctly and the gateway routes the request
to the expected workspace. The response on `/api/2.0/preview/scim/v2/Me`
echoes the workspace ID on `x-databricks-org-id`, which is why the
response read site stays on the legacy name.
- Added a new acceptance test `TestAccUnifiedHostSendsWorkspaceIdHeader`
in `internal/unified_host_test.go`. It hooks a capturing
`http.RoundTripper` into a workspace client built against a unified host
and verifies on the wire that (1) the SDK sends
`X-Databricks-Workspace-Id` and not `X-Databricks-Org-Id` on the
request, (2) the server still echoes `X-Databricks-Org-Id` on the
response, and (3) the SCIM Me call succeeds end-to-end. Skips when the
workspace-test environment variables (`UNIFIED_HOST`,
`THIS_WORKSPACE_ID`, `TEST_ACCOUNT_ID`, `DATABRICKS_CLIENT_ID`,
`DATABRICKS_CLIENT_SECRET`) are missing.
---------
Signed-off-by: Divyansh Vijayvergia <divyansh.vijayvergia@databricks.com>1 parent 5b3c359 commit 0a030bd
43 files changed
Lines changed: 1108 additions & 1001 deletions
File tree
- config
- internal
- testspecs/service
- httpcallv2
- idempotencytesting
- jsonmarshallv2
- lrotesting
- service
- agentbricks
- apps
- bundle
- catalog
- cleanrooms
- compute
- dashboards
- database
- dataclassification
- dataquality
- environments
- files
- iamv2
- iam
- jobs
- knowledgeassistants
- marketplace
- ml
- oauth2
- pipelines
- postgres
- qualitymonitorv2
- serving
- settingsv2
- settings
- sharing
- sql
- supervisoragents
- tags
- vectorsearch
- workspace
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments