Skip to content

Accept ?w= URL query parameter alongside ?o=#5373

Merged
andrewnester merged 3 commits into
new-workspace-parameterfrom
accept-workspace-id-url-param
Jun 1, 2026
Merged

Accept ?w= URL query parameter alongside ?o=#5373
andrewnester merged 3 commits into
new-workspace-parameterfrom
accept-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 new workspace addressing header. This PR extends the CLI's URL parsers to recognize ?w= in addition to the existing ?o= and ?workspace_id= spellings. Pure addition; no existing URL changes meaning.

Stacked on top of #5368 (which renames the request header to X-Databricks-Workspace-Id); the two together complete the input + wire side of the URL/header migration for the core CLI.

Affected entry points

  • databricks api <verb> <path?w=...> — workspace ID is extracted from the path and sent as the routing header on the call.
  • databricks auth login --host "https://...?w=..." — workspace ID is extracted from the host URL and persisted to the profile.
  • workspace.host in databricks.yml — uses the same shared parser (libs/auth.ExtractHostQueryParams).

Precedence

When more than one spelling appears on a single URL, ?o= > ?w= > ?workspace_id=. The o-first rule preserves the resolution of any URL already pasted from older UI builds, shell history, or committed databricks.yml files.

Rename

extractOrgIDFromQuery (in cmd/api/api.go) → extractWorkspaceIDFromQuery. The helper now returns the value under any of the recognized parameter names, so the old name became misleading. Unexported, single call site; updated atomically.

Files

  • libs/auth/hostparams.go — adds the q.Get("w") branch in ExtractHostQueryParams; comment refreshed to document the three accepted forms and precedence.
  • cmd/api/api.go — adds workspaceIDQueryParam = "w" const; renames extractor and updates its body to check o then w.
  • cmd/auth/login.go — help text updated to recommend ?w= and note that ?o= / ?workspace_id= are still accepted.
  • libs/auth/hostparams_test.go — new cases for ?w=, precedence, and non-numeric rejection.
  • cmd/api/api_test.go — new cases in TestExtractWorkspaceIDFromQuery (renamed) and TestResolveOrgID covering ?w= and the o-wins-over-w precedence.
  • acceptance/cmd/api/workspace-id-from-w-query/ — new acceptance test mirroring workspace-id-from-query/ but exercising the ?w= path. The original ?o= test stays unchanged as a regression check.

Test plan

  • `go test ./libs/auth/... ./cmd/api/... ./cmd/auth/... -count=1` — green
  • `go test ./acceptance -run 'TestAccept/cmd/api|TestAccept/cmd/auth|TestAccept/auth'` — green
  • `./task lint-q` — 0 issues
  • `./task fmt` — no changes

@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

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

Commit: 815f916

Run: 26646897134

The Databricks UI is migrating from ?o=<workspace-id> to ?w=<workspace-id>
as the SPOG URL query parameter, matching the new workspace addressing
header. Extend the CLI's URL parsers to recognize ?w= in addition to the
existing ?o= and ?workspace_id= spellings. Pure addition; no existing URL
changes meaning.

This affects:

- databricks api <verb> <path?w=...> — workspace ID extracted from the
  path and sent as the routing header on the call.
- databricks auth login --host "https://...?w=..." — workspace ID
  extracted from the host URL and persisted to the profile.
- workspace.host in databricks.yml — same parser is reused.

When more than one spelling is present on a single URL, ?o= takes
precedence over ?w=, which takes precedence over ?workspace_id=. The "o"
precedence preserves the meaning of any URL already pasted from older UI
builds, shell history, or committed databricks.yml files.

The cmd/api helper extractOrgIDFromQuery is renamed to
extractWorkspaceIDFromQuery to reflect that it now returns the value
under multiple recognized parameter names.
The new X-Databricks-Workspace-Id routing header accepts non-numeric
workspace identifiers (e.g. connection-style strings) in addition to
classic numeric workspace IDs; the server disambiguates. The URL parser
was rejecting any non-numeric value via strconv.ParseInt and silently
dropping it, which would block pasted URLs that carry one of the new
identifier shapes.

Remove the numeric validation from all three branches (?o=, ?w=,
?workspace_id=) in ExtractHostQueryParams and pass the raw value through.
Affects every caller of the helper:

- databricks auth login --host
- workspace.host in databricks.yml (via bundle/config/workspace.go)

Flip the existing "non-numeric is skipped" tests in hostparams_test.go
and host_env_test.go to "non-numeric is passed through". Add a positive
test case for a UUID-shaped connection-style identifier.
@Divyansh-db Divyansh-db force-pushed the accept-workspace-id-url-param branch from 4d05fbd to 144792d Compare May 29, 2026 13:23
@Divyansh-db Divyansh-db temporarily deployed to test-trigger-is May 29, 2026 13:23 — with GitHub Actions Inactive
@Divyansh-db Divyansh-db temporarily deployed to test-trigger-is May 29, 2026 13:23 — with GitHub Actions Inactive
Legacy URL spellings ?o= and ?workspace_id= predate the broader workspace
identifier shapes the new routing header accepts. URLs in databricks.yml,
browser bookmarks, and shell history that use those forms are always
numeric, so keep the strconv.ParseInt validation on those branches to
silently drop garbage values (matching pre-PR behavior).

?w= is the new spelling and must pass non-numeric connection-style
identifiers through unchanged.

Adjust the test cases: "non-numeric ?o= is skipped" and "non-numeric
?workspace_id= is skipped" go back to expecting the value to be dropped.
The ?w= non-numeric and UUID-shaped positive cases stay.
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 focused PR #5373 range on top of new-workspace-parameter. No blocking findings.

Validated locally:

  • go test ./libs/auth/... ./cmd/api/... ./cmd/auth/... -count=1
  • go test ./acceptance -run TestAccept/cmd/api/workspace-id-from-w-query -count=1
  • git diff --check c579a1c..origin/pr/5373

@andrewnester andrewnester merged commit 38859c1 into new-workspace-parameter Jun 1, 2026
24 checks passed
@andrewnester andrewnester deleted the accept-workspace-id-url-param branch June 1, 2026 11: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