You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d4a79f8
Browse filesBrowse the repository at this point in the historyBrowse files
Improve errors for workspace commands against account console hosts (#5506)
## Why
Profiles that point at a classic account console host
(https://accounts.cloud.databricks.com and friends) only serve
account-level APIs. When users run workspace commands against such a
profile, the console returns junk and the CLI surfaces it as-is:
`databricks jobs list` fails with "Error: received HTML response instead
of JSON", and other paths return a bare HTTP 400 with "Unable to load
OAuth Config". Nothing tells the user the host is the problem.
Worse, the existing account-only profile error said "Edit the profile to
set workspace_id to a real ID", which can never work on an account
console host (it serves no workspace APIs) and is exactly how the broken
profiles in the linked issue were created.
These failure shapes are unstructured (HTML pages, bare-string bodies,
no error codes), so there is no reliable way to detect "this API is not
available here" from the response. Instead, the CLI now adds context
based on what it does know: the command operates against a workspace,
and the host is an account console host.
Relates to #5479
## Changes
Before, workspace commands against an account console host failed with
raw junk errors and misleading advice; now the CLI explains the host
mismatch and points to a fix.
1. Failure-time hint: when a command fails and a workspace client was
configured on the command context and the host is a classic account
console host, `cmd/root.Execute` appends a note via the new
`auth.AppendAccountHostHint`:
```
Note: profile "acc" points to a Databricks account console host
(https://accounts.cloud.databricks.com), which serves only account-level
APIs.
Workspace commands need a workspace host: run `databricks auth login
--host https://<workspace-url>`, or use `databricks account ...`
commands with this profile
```
The note fires for any error from such commands (workspace commands can
never succeed against these hosts today), composes with the existing
401/403 enrichment, and stays silent for `databricks account ...`
commands, auth commands, and anything that did not configure a workspace
client. Adds `cmdctx.HasWorkspaceClient` as the non-panicking lookup.
2. Host-aware `ErrAccountOnlyProfile`: the error now carries the
profile's canonical host. For account console hosts it says the host
serves only account-level APIs and suggests `databricks auth login
--host https://<workspace-url>` or `databricks account ...` commands,
instead of the impossible "set workspace_id to a real ID" advice. Other
hosts (SPOG/unified) keep the existing wording, and `MustAnyClient`
still matches the type to fall through to the account client.
## Test plan
- [x] Unit tests for both `AppendAccountHostHint` message variants
(profile and no profile), the non-account-host and empty-host
passthroughs, error chain preservation, and composition with
`EnrichAuthError` (libs/auth)
- [x] Table-driven trigger tests through `Execute`: hint fires for
workspace client + account console host; stays silent for workspace
host, account client, and no client (cmd/root)
- [x] Unit tests for both `ErrAccountOnlyProfile` message variants and
host plumb-through via `workspaceClientOrPrompt`, plus the existing
`MustAnyClient` fall-through test still passes (cmd/root)
- [x] `go test ./cmd/root/... ./libs/auth/... ./libs/cmdctx/...`
- [x] `./task fmt-q`, `./task lint-q`, `./task checks`
- [x] Manual smoke test with a fake `.databrickscfg`: verified the note
on `jobs list`, the new account-only message, and no note on `account
groups list`
No acceptance tests: the hint path needs a live workspace client against
a real `accounts.*` host, and real domains are forbidden in fixtures;
unit coverage exercises the same seams.
This pull request and its description were written by Isaac.
Copy file name to clipboardExpand all lines: NEXT_CHANGELOG.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,6 @@
13
13
*`databricks auth profiles --skip-validate` no longer makes any network calls; the host metadata fetch is skipped along with validation ([#5530](https://github.com/databricks/cli/pull/5530)).
14
14
15
15
16
-
17
16
### Bundles
18
17
* Set the default `data_security_mode` to `DATA_SECURITY_MODE_AUTO` in bundle templates ([#5452](https://github.com/databricks/cli/pull/5452)).
19
18
* Mark vector search index index_subtype as backend_default to prevent drift after deployment ([#5454](https://github.com/databricks/cli/pull/5454)).
returnfmt.Sprintf("profile %q points to a Databricks account console host (%s), which serves only account-level APIs; this command requires a workspace. Run `databricks auth login --host https://<workspace-url>` to create a workspace profile, or use `databricks account ...` commands with this profile", e.profileName, e.host)
94
+
}
85
95
returnfmt.Sprintf("profile %q has no workspace_id set (account-only); this command requires a workspace. Edit the profile to set workspace_id to a real ID, or pass --profile with a workspace-scoped profile", e.profileName)
86
96
}
87
97
88
98
// accountOnlyProfileError describes why a workspace command can't run against
89
99
// a profile that has an account_id but no workspace_id.
want: "profile \"acc\" points to a Databricks account console host (https://accounts.test), which serves only account-level APIs; "+
562
+
"this command requires a workspace. Run `databricks auth login --host https://<workspace-url>` to create a workspace profile, "+
563
+
"or use `databricks account ...` commands with this profile",
564
+
},
565
+
{
566
+
// On non-account-console hosts (SPOG/unified) workspace APIs are
567
+
// served, so setting workspace_id is still the right fix.
returnfmt.Errorf("%w\n\nNote: %s points to a Databricks account console host (%s), which serves only account-level APIs.\nWorkspace commands need a workspace host: run `databricks auth login --host https://<workspace-url>`, or use `databricks account ...` commands%s", err, subject, host, scope)
134
+
}
135
+
115
136
// writeReauthSteps writes auth-type-aware re-authentication suggestions for 401 errors.
"Note: profile \"acc\" points to a Databricks account console host (https://accounts.test), which serves only account-level APIs.\n"+
276
+
"Workspace commands need a workspace host: run `databricks auth login --host https://<workspace-url>`, or use `databricks account ...` commands with this profile",
"Note: this configuration points to a Databricks account console host (https://accounts.test), which serves only account-level APIs.\n"+
283
+
"Workspace commands need a workspace host: run `databricks auth login --host https://<workspace-url>`, or use `databricks account ...` commands",
0 commit comments