Skip to content

databricks experimental open: emit ?w= URL query parameter#5369

Merged
andrewnester merged 5 commits into
mainfrom
emit-workspace-id-url-param
Jun 1, 2026
Merged

databricks experimental open: emit ?w= URL query parameter#5369
andrewnester merged 5 commits into
mainfrom
emit-workspace-id-url-param

Conversation

@Divyansh-db
Copy link
Copy Markdown
Contributor

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 switches 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 anywhere the CLI parses host URLs; only the emitted form changes.

Scope

  • libs/workspaceurls/urls.goworkspaceBaseURL now adds w=<id>, docstring on BuildResourceURL updated.
  • 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.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. The bundle path can flip in a separate change.

Test plan

  • go test ./libs/workspaceurls/... ./cmd/experimental/... — green
  • go test ./acceptance -run 'TestAccept/experimental/open' — green (golden file regenerated)
  • ./task lint-q — 0 issues; ./task fmt — no changes

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
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

eng-dev-ecosystem-bot commented May 29, 2026

Commit: bf65882

Run: 26753462432

@andrewnester andrewnester requested a review from simonfaltum May 29, 2026 12:52
Comment thread libs/workspaceurls/urls.go Outdated

values := baseURL.Query()
values.Add("o", orgID)
values.Add("w", wsID)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewnester andrewnester self-requested a review May 29, 2026 12:57
Copy link
Copy Markdown
Contributor

@hectorcast-db hectorcast-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Member

@simonfaltum simonfaltum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

## 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 andrewnester enabled auto-merge June 1, 2026 11:59
@andrewnester andrewnester added this pull request to the merge queue Jun 1, 2026
Merged via the queue into main with commit c71ec40 Jun 1, 2026
28 of 29 checks passed
@andrewnester andrewnester deleted the emit-workspace-id-url-param branch June 1, 2026 12:56
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.

5 participants