Improve auth token error formatting for easier copy-paste#4602
Closed
jamesbroadhead wants to merge 5 commits into
Closed
Improve auth token error formatting for easier copy-paste#4602jamesbroadhead wants to merge 5 commits into
jamesbroadhead wants to merge 5 commits into
Conversation
When auth fails, the suggested `databricks auth login` command was printed on the same line as the error and config details, making it hard to copy. Split the message across multiple lines so the command is visually distinct and easy to select. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
andrewnester
approved these changes
Feb 26, 2026
|
|
||
| ### CLI | ||
| * Add `completion install`, `uninstall`, and `status` subcommands ([#4581](https://github.com/databricks/cli/pull/4581)) | ||
| * Improve `auth token` error formatting for easier copy-paste of login commands |
Contributor
There was a problem hiding this comment.
Please include a link to the PR here
simonfaltum
approved these changes
Mar 3, 2026
…formatting # Conflicts: # NEXT_CHANGELOG.md # cmd/auth/token_test.go
Contributor
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
Contributor
Author
|
Superseded by #5115 — re-opened from an upstream branch instead of a fork (so CI can run). Was previously approved by @andrewnester and @simonfaltum. |
auto-merge was automatically disabled
April 28, 2026 16:06
Pull request was closed
jamesbroadhead
added a commit
that referenced
this pull request
May 18, 2026
Reformats the `auth token` error so the suggested `databricks auth login` command lands on its own line with blank-line padding above and below, making it easy to select and copy. Also pulls every render path through the new `BuildLoginCommand` helper so they all benefit from shell-quoting and consistent --workspace-id emission. Rebased onto current main; addresses simonfaltum's May 7 review: - **Blocking fix**: `writeReauthSteps`'s `AuthTypeDatabricksCli` profile branch now routes through `BuildLoginCommand(ctx, cfg.Profile, cfg.WorkspaceID, nil)` instead of the raw `fmt.Fprintf(... "--profile %s", ...)`. Previously this branch (the most common 401 path) missed both shell-quoting and --workspace-id; on unified/SPOG hosts the suggested command could target the wrong workspace. - Changelog link points at #5115 (was the superseded #4602). - `RewriteAuthError` unified on the blank-line-padded layout to match `helpfulError`. Acceptance test golden file regenerated. - `BuildLoginCommand` doc-comment expanded with two clarifications: (a) why the profile path re-emits --workspace-id (pin to the workspace the failing call resolved against, even if the profile's persisted value drifted), and (b) why Account/Workspace OAuth cases drop workspaceID (account args target the account API; workspace args already identify a workspace by host). - Two new test cases on `TestBuildLoginCommand_AppendsWorkspaceID`: negative assertions that `WorkspaceOAuthArgument` and `AccountOAuthArgument` paths omit `--workspace-id` even when provided, plus a shell-quoting case (`profile = "weird name"`). 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.
Changes
Format the
auth tokenerror message across multiple lines so thesuggested
databricks auth logincommand is on its own line and easyto copy-paste.
Before:
After:
Why
When auth fails, the suggested login command was printed on the same line as the error and config details, making it difficult to select and copy. This follows the same multi-line pattern already used by
RewriteAuthErrorfor invalid refresh token errors.Tests
go test ./cmd/auth/ -run TestToken_loadToken)go test ./acceptance/... -run TestAccept/cmd/auth/token)