Commit 59ad59e
authored
config: extract ?o=/?a= from Host URL (#1699)
## Changes
Pasting a SPOG URL from the Databricks UI (e.g.
`https://acme.databricks.net/?o=12345`) into `Config.Host` previously
dropped the workspace identifier on the way through `fixHostIfNeeded`:
the function stripped path and query without promoting them to dedicated
fields. The request then went out without an `X-Databricks-Org-Id`
header, the server couldn't route it, and the response came back as the
login HTML page, surfacing as `ErrHTMLContent` (`"received HTML response
instead of JSON"`).
This change recognizes `?o=`/`?workspace_id=` and `?a=`/`?account_id=`
as part of host sanitization and promotes them into
`Config.WorkspaceID`/`Config.AccountID` when those fields are empty.
Existing values are never overwritten.
The same fix is going in at the CLI level in
[databricks/cli#5337](databricks/cli#5337) as a
stopgap that pre-processes `DATABRICKS_HOST`. Once this SDK fix lands
and the CLI bumps the SDK version, the CLI-side workaround can be
removed.
## Tests
- New table-driven test
`TestConfig_fixHostIfNeeded_extractsWorkspaceIDFromQuery` in
`config/config_test.go` covers: `?o=` promotion, `?workspace_id=`
promotion, `?a=` promotion, both together, existing
`WorkspaceID`/`AccountID` preserved, non-numeric `?o=` dropped, host
without query unchanged.
- `make fmt test lint` clean.
NO_CHANGELOG=true
---------
Signed-off-by: simon <simon.faltum@databricks.com>1 parent 0a030bd commit 59ad59e
2 files changed
Lines changed: 113 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
627 | 628 | | |
628 | 629 | | |
629 | 630 | | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
630 | 645 | | |
631 | 646 | | |
632 | 647 | | |
| |||
637 | 652 | | |
638 | 653 | | |
639 | 654 | | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
640 | 677 | | |
641 | 678 | | |
642 | 679 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1307 | 1307 | | |
1308 | 1308 | | |
1309 | 1309 | | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
0 commit comments