databricks experimental open: emit ?w= URL query parameter#5369
Merged
Conversation
The Databricks UI is migrating from ?o=<workspace-id> to ?w=<workspace-id> as the SPOG URL query parameter, matching the recent workspace addressing header rename. Switch BuildResourceURL in libs/workspaceurls to write ?w= when appending the workspace identifier. This affects URLs printed by databricks experimental open. The legacy ?o= URL spelling remains a valid input wherever the CLI parses host URLs; only the emitted form changes. bundle/config/mutator/initialize_urls.go also adds a workspace identifier query parameter, but it does so before calling ResourceURL with an already-built baseURL, so this change does not affect bundle output.
# Conflicts: # cmd/experimental/workspace_open_test.go
Collaborator
|
Commit: bf65882 |
andrewnester
approved these changes
May 29, 2026
|
|
||
| values := baseURL.Query() | ||
| values.Add("o", orgID) | ||
| values.Add("w", wsID) |
Contributor
There was a problem hiding this comment.
There's a similar change needed here: https://github.com/databricks/cli/blob/main/bundle/config/mutator/initialize_urls.go#L56
Contributor
hectorcast-db
left a comment
There was a problem hiding this comment.
Current code LGTM. I will review it again after the missing change is added.
bundle/config/mutator/initialize_urls.go is the bundle-side counterpart of libs/workspaceurls/workspaceBaseURL: it appends ?o=<workspace-id> to every resource URL printed by `databricks bundle summary`. Flip it to emit ?w= to match the new workspace addressing convention. The 12 bundle resource URL builders that consume the baseURL (alerts, apps, pipelines, jobs, dashboards, experiments, models, model serving, registered models, clusters, sql warehouses, vector search) all inherit the new spelling without code changes since they just append the resource path/fragment to the baseURL. Updates: - bundle/config/mutator/initialize_urls.go: emit ?w= instead of ?o=, rename local orgId → workspaceID, refresh the comment. - bundle/config/mutator/initialize_urls_test.go: ~10 expected-URL assertions flipped from ?o= to ?w=. - 18 acceptance/bundle/** golden files regenerated with ?w=. - 12 acceptance/bundle/** test.toml scrub patterns widened from \?o=... to \?[ow]=... so they match both the new (?w=) and legacy (?o=) URL parameter forms. `Run URL: ...?o=...` lines in run / deploy / spark task / integration_whl fixtures are intentionally left as ?o= — those URLs come from the platform API's RunPageUrl response field, not from CLI code, and the API response side has not migrated yet (asymmetric migration; the platform still echoes ?o= until the response-side rename ships).
The acceptance/pipelines tree exercises the pipelines-binary mode of the CLI; `databricks pipelines deploy` and friends print resource URLs via the same bundle/config/mutator/initialize_urls.go path that PR 3 just flipped to ?w=. Regenerate the 19 affected golden files to match. The open-after-deployment/output.txt golden is part of a macOS-only test (its test.toml sets GOOS.windows = false and GOOS.linux = false) so ./task test-update can't regenerate it locally; that one is updated by hand as a mass literal swap, which is the explicit exception called out in .agent/rules/auto-generated-files.md.
simonfaltum
approved these changes
May 30, 2026
Member
simonfaltum
left a comment
There was a problem hiding this comment.
Reviewed the URL emission changes and the related stack. The only remaining nit I found on this PR is that this is user-visible output and does not add a NEXT_CHANGELOG.md entry, but I do not think that should block approval. The ?w= parsing concern is handled in the companion PR #5373, so this stack should land with that parser support before/alongside this change.
hectorcast-db
approved these changes
Jun 1, 2026
## Summary The CLI calls \`CurrentWorkspaceID\` on the workspace client in five places to obtain the workspace ID. The SDK helper returns \`(int64, error)\` and reads the value from the \`X-Databricks-Org-Id\` response header on \`/api/2.0/preview/scim/v2/Me\`, parsing with \`strconv.ParseInt\`. Every consumer then formats the int64 back to a string at its own boundary — or, in two cases under \`experimental/ssh\`, embeds it directly with \`%d\`. This PR introduces a small helper that returns the workspace ID as a string and short-circuits the API call when the workspace ID is already configured on the client, and migrates the five consumers to use it. As a side effect, the in-CLI workspace ID flow becomes string-typed end-to-end, so non-numeric workspace identifiers (e.g. connection-style IDs) flow through cleanly when configured. ## The helper \`libs/auth.ResolveWorkspaceID(ctx, w)\`: 1. If \`w.Config.WorkspaceID\` is set (and not the CLI-only \`"none"\` sentinel), return it verbatim. No API call. 2. Otherwise call \`w.CurrentWorkspaceID(ctx)\` and return \`strconv.FormatInt(id, 10)\`. The fast path is also a small performance win — the workspace ID is already configured in the common SPOG case (set via \`--workspace-id\`, \`DATABRICKS_WORKSPACE_ID\`, \`workspace_id\` in \`.databrickscfg\`, or \`?w=\`/\`?o=\` on a host URL), and the existing code unconditionally hit \`/Me\` to resolve the same value. ## Consumer migrations Five call sites switch from \`CurrentWorkspaceID\` to \`ResolveWorkspaceID\`: - \`cmd/experimental/workspace_open.go\` (\`databricks experimental open\`) - \`bundle/config/mutator/initialize_urls.go\` (\`databricks bundle summary\` and any other bundle command that renders resource URLs) - \`cmd/apps/run_local.go\` (\`databricks apps run-local\`) - \`experimental/ssh/internal/client/websockets.go\` (\`databricks experimental ssh\` driver-proxy URL) - \`experimental/ssh/internal/client/client.go\` (\`databricks experimental ssh\` cluster-metadata fetch) ## Downstream signatures widen from int64 to string - \`libs/workspaceurls.BuildResourceURL\`, \`workspaceBaseURL\` - \`libs/apps/runlocal.Config.WorkspaceID\`, \`NewConfig\` - The two \`fmt.Sprintf\` calls in \`experimental/ssh\` swap \`%d\` → \`%s\`. The \`/driver-proxy-api/o/<workspace-id>/...\` URL keeps its legacy \`o\` path segment — that's a separate platform-side URL scheme decision from the \`?o=\`/\`?w=\` query parameter migration. ## Behavior change summary - Configured workspace ID flow: no behavior change. The value the CLI sends as a routing header / appends to a URL / sets as \`DATABRICKS_WORKSPACE_ID\` for child processes is the same string it was before. - Resolved-from-\`/Me\` flow: also no behavior change. The SDK still enforces numeric in that path; the helper just stringifies the result. - Non-numeric configured IDs (UUID-shaped connection-style identifiers set via \`?w=<uuid>\` etc.): newly supported end-to-end through the five consumers. Previously the int64 typing dropped them. ## Out of scope - \`libs/auth/introspect.go\` declares \`WorkspaceID int64\` on the \`/api/2.0/tokens/introspect\` response. Different endpoint, separate follow-up. - \`cmd/auth/login.go\`'s workspace picker reads \`WorkspaceId int64\` from the SDK's \`Workspaces.List\` schema. Upstream SDK change. - The \`/driver-proxy-api/o/<workspace-id>/\` URL path segment in \`experimental ssh\` keeps the legacy \`o\` form. That's a separate platform-side URL scheme decision; only the format specifier changes here. ## Test plan - [x] \`go test ./libs/auth/... ./libs/workspaceurls/... ./libs/apps/... ./bundle/config/mutator/... ./cmd/experimental/... ./cmd/apps/... ./experimental/ssh/...\` — green - [x] \`./task test-update\` over the previously-affected acceptance suites produces no diff (behavior preserved) - [x] \`./task lint-q\` — 0 issues; \`./task fmt\` — clean
andrewnester
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Databricks UI is migrating from
?o=<workspace-id>to?w=<workspace-id>as the SPOG URL query parameter, matching the recent workspace addressing header rename. This PR switchesBuildResourceURLinlibs/workspaceurlsto write?w=when appending the workspace identifier.This affects URLs printed by
databricks experimental open. The legacy?o=URL spelling remains a valid input anywhere the CLI parses host URLs; only the emitted form changes.Scope
libs/workspaceurls/urls.go—workspaceBaseURLnow addsw=<id>, docstring onBuildResourceURLupdated.libs/workspaceurls/urls_test.go— expected URLs flipped.cmd/experimental/workspace_open_test.go— expected URLs flipped.acceptance/experimental/open/output.txt— regenerated via./task test-update.bundle/config/mutator/initialize_urls.goalso adds a workspace identifier query parameter, but it does so before callingResourceURLwith an already-built baseURL, so this change does not affect bundle output. The bundle path can flip in a separate change.Test plan
go test ./libs/workspaceurls/... ./cmd/experimental/...— greengo test ./acceptance -run 'TestAccept/experimental/open'— green (golden file regenerated)./task lint-q— 0 issues;./task fmt— no changes