auth: clear error for PAT profile on SPOG without workspace_id#5341
Open
simonfaltum wants to merge 3 commits into
Open
auth: clear error for PAT profile on SPOG without workspace_id#5341simonfaltum wants to merge 3 commits into
simonfaltum wants to merge 3 commits into
Conversation
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 "Credential was not sent or was of an unsupported type for this API" error from the auth endpoint. Detect this combination (auth_type=pat, SPOG discovery signal, workspace_id empty) up front in `workspaceClientOrPrompt` and return 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. Co-authored-by: Isaac
Contributor
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
Collaborator
|
Commit: 32ce366 |
GPT review pointed out the existing test seeded AuthType and DiscoveryURL manually, so it didn't prove the detector still fires when those fields come from the SDK during NewWorkspaceClient (the realistic flow). Add a test that writes a .databrickscfg with only `host` and `token` (matching the bug bash repro), points the host at an httptest server serving SPOG-style .well-known metadata, and runs through the public workspaceClientOrPrompt entry point. AuthType is populated by the SDK credential probe; DiscoveryURL is populated by host metadata resolution. The detector still catches the case. Co-authored-by: Isaac
The Windows GitHub runner doesn't have IPv6 configured. httptest.NewServer
tried 127.0.0.1 first and fell through to "[::1]:0" on retry, then
panicked: "listen tcp6 [::1]:0: socket: The requested service provider
could not be loaded or initialized." Build the listener directly with
net.Listen("tcp4", "127.0.0.1:0") and hand it to httptest.
Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
`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 = matching the workspace the token was minted in
```
Test plan