Commit aaebbe8
authored
auth: clear error for PAT profile on SPOG without workspace_id (#5341)
## Why
Personal access tokens are workspace-scoped. When a PAT profile points
at a SPOG host (account-scoped OIDC discovery) without \`workspace_id\`,
the SDK can't add the routing identifier, the request lands on the
account-plane where PATs aren't accepted, and the user sees the opaque
error \"Credential was not sent or was of an unsupported type for this
API\" from the auth endpoint. Reported in a bug bash.
Reproduced against \`db-deco-test.databricks.com\`:
\`\`\`
[spog-pat-no-wid]
host = https://db-deco-test.databricks.com
token = dapi...
$ databricks auth describe --profile spog-pat-no-wid
Unable to authenticate: Credential was not sent or was of an unsupported
type for this API. [ReqId: ...]
\`\`\`
## Changes
- Before: PAT-on-SPOG without \`workspace_id\` failed with the opaque
credentials error.
- Now: \`workspaceClientOrPrompt\` detects the combination
(\`auth_type=pat\` + SPOG discovery signal + \`workspace_id\` empty)
before any API call and returns a message that names the profile,
explains the routing constraint, and points at the fix: add
\`workspace_id = <id>\` for the workspace the token was minted in.
\`databricks auth describe --profile spog-pat-no-wid\` now prints:
\`\`\`
Unable to authenticate: profile \"spog-pat-no-wid\" uses PAT auth on a
SPOG host but is missing workspace_id; PATs are workspace-scoped, so the
request can't be routed. Edit the profile to add workspace_id = <id>
matching the workspace the token was minted in
\`\`\`
## Test plan
- [x] Reproduced against \`db-deco-test.databricks.com\` with a PAT
profile that has no \`workspace_id\`; saw the opaque \"Credential was
not sent\" error.
- [x] Same profile with the fix → clear, actionable error message naming
the profile and pointing at the fix (verified with \`auth describe\` and
\`current-user me\`).
- [x] Existing \`spog-deco-aws\` (PAT with valid \`workspace_id\`) still
works against the same host — no regression.
- [x] New unit tests: \`TestIsPATOnSPOGWithoutWorkspaceID\`,
\`TestWorkspaceClientOrPromptRejectsPATOnSPOGWithoutWorkspaceID\`
- [x] \`go test ./cmd/root/...\`, \`./task checks\`, \`./task lint-q\`1 parent 5a2669c commit aaebbe8
2 files changed
Lines changed: 160 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
55 | 75 | | |
56 | 76 | | |
57 | 77 | | |
| |||
221 | 241 | | |
222 | 242 | | |
223 | 243 | | |
224 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
225 | 248 | | |
226 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
227 | 258 | | |
228 | 259 | | |
229 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
457 | 516 | | |
458 | 517 | | |
459 | 518 | | |
| |||
490 | 549 | | |
491 | 550 | | |
492 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
493 | 621 | | |
494 | 622 | | |
495 | 623 | | |
| |||
0 commit comments