Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
25 changes: 25 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading