diff --git a/config/config.go b/config/config.go index 7e240096d..8ba92ab87 100644 --- a/config/config.go +++ b/config/config.go @@ -653,6 +653,14 @@ func (c *Config) fixHostIfNeeded() error { } func workspaceIDFromQuery(q url.Values) string { + // ?w= is the unified workspace addressing query parameter. It supersedes + // the older ?o=/?workspace_id= forms and accepts a broader range of + // workspace identifier formats — both classic numeric workspace IDs and + // other identifier formats the server understands — so we don't apply the + // numeric-only validation that we use for ?o=/?workspace_id=. + if v := q.Get("w"); v != "" { + return v + } for _, key := range []string{"o", "workspace_id"} { v := q.Get(key) if v == "" { diff --git a/config/config_test.go b/config/config_test.go index eaf8661a6..f3b73f269 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1362,6 +1362,31 @@ func TestConfig_fixHostIfNeeded_extractsWorkspaceIDFromQuery(t *testing.T) { host: "https://acme.databricks.net/?o=notanumber", wantHost: "https://acme.databricks.net", }, + { + name: "?w= with numeric value promoted to WorkspaceID", + host: "https://acme.databricks.net/?w=12345", + wantHost: "https://acme.databricks.net", + wantWorkspaceID: "12345", + }, + { + name: "?w= with non-numeric value promoted to WorkspaceID", + host: "https://acme.databricks.net/?w=7a99b43c-b46c-432b-b0a7-814217701909", + wantHost: "https://acme.databricks.net", + wantWorkspaceID: "7a99b43c-b46c-432b-b0a7-814217701909", + }, + { + name: "?w= takes precedence over ?o=", + host: "https://acme.databricks.net/?w=12345&o=99999", + wantHost: "https://acme.databricks.net", + wantWorkspaceID: "12345", + }, + { + name: "existing WorkspaceID is preserved over ?w=", + host: "https://acme.databricks.net/?w=12345", + workspaceID: "99999", + wantHost: "https://acme.databricks.net", + wantWorkspaceID: "99999", + }, { name: "host without query is unchanged", host: "https://acme.databricks.net",