Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/cli/docker-duplicate-profile-hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Suggest `databricks auth logout --profile <profile-name> --delete` when multiple profiles match the same workspace in `databricks auth docker` commands. ([#7363](https://github.com/databricks/cli/pull/7363))
2 changes: 1 addition & 1 deletion acceptance/cmd/auth/docker/configure-errors/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Error: profile "blank-auth" uses auth_type "". Docker credential helper requires
=== Another profile already maps to the workspace

>>> musterr [CLI] auth docker configure docker-test
Error: multiple Databricks profiles match workspace ID [WORKSPACE_ID]: duplicate and docker-test. Remove duplicate workspace_id entries before using Docker credential helper
Error: multiple Databricks profiles match workspace ID [WORKSPACE_ID]: duplicate and docker-test. Docker credential helper requires exactly one profile per workspace. Remove the duplicate profile with: databricks auth logout --profile <profile-name> --delete

=== Nothing changed
Docker config not created; profiles unchanged
2 changes: 1 addition & 1 deletion acceptance/cmd/auth/docker/token/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ Error: no Databricks profile found for workspace ID 444555666 from registry host
=== Multiple profiles for the workspace

>>> musterr [CLI] auth docker token
Error: multiple Databricks profiles match workspace ID [WORKSPACE_ID]: docker-test and duplicate. Remove duplicate workspace_id entries before using Docker credential helper
Error: multiple Databricks profiles match workspace ID [WORKSPACE_ID]: docker-test and duplicate. Docker credential helper requires exactly one profile per workspace. Remove the duplicate profile with: databricks auth logout --profile <profile-name> --delete
8 changes: 6 additions & 2 deletions libs/dockercredentials/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func EnsureUniqueProfile(ctx context.Context, profiler profile.Profiler, p profi
return nil
}

return fmt.Errorf("multiple Databricks profiles match workspace ID %s: %s. Remove duplicate workspace_id entries before using Docker credential helper", workspaceID, strings.Join(names, " and "))
return duplicateProfilesError(workspaceID, names)
}

// ProfileForRegistry returns the Docker credential helper profile for registry.
Expand All @@ -99,10 +99,14 @@ func ProfileForRegistry(ctx context.Context, profiler profile.Profiler, registry
case 1:
return matchingProfiles[0], nil
default:
return profile.Profile{}, fmt.Errorf("multiple Databricks profiles match workspace ID %s: %s. Remove duplicate workspace_id entries before using Docker credential helper", registry.WorkspaceID, strings.Join(matchingProfiles.Names(), " and "))
return profile.Profile{}, duplicateProfilesError(registry.WorkspaceID, matchingProfiles.Names())
}
}

func duplicateProfilesError(workspaceID string, names []string) error {
return fmt.Errorf("multiple Databricks profiles match workspace ID %s: %s. Docker credential helper requires exactly one profile per workspace. Remove the duplicate profile with: databricks auth logout --profile <profile-name> --delete", workspaceID, strings.Join(names, " and "))
}

// RewriteProfileError adds Docker profile context to authentication errors.
func RewriteProfileError(ctx context.Context, p profile.Profile, err error) error {
if rewritten, rewrittenErr := auth.RewriteAuthError(ctx, p.Host, p.AccountID, p.Name, err); rewritten {
Expand Down
6 changes: 3 additions & 3 deletions libs/dockercredentials/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestEnsureUniqueProfile(t *testing.T) {
name: "duplicate workspace ID",
profiles: profile.Profiles{selected, workspaceProfile("dev")},
selected: selected,
wantErr: "multiple Databricks profiles match workspace ID 123456789: prod and dev. Remove duplicate workspace_id entries before using Docker credential helper",
wantErr: "multiple Databricks profiles match workspace ID 123456789: prod and dev. Docker credential helper requires exactly one profile per workspace. Remove the duplicate profile with: databricks auth logout --profile <profile-name> --delete",
},
{
name: "unsupported duplicate",
Expand All @@ -172,7 +172,7 @@ func TestEnsureUniqueProfile(t *testing.T) {
Host: workspaceHost,
AuthType: auth.AuthTypeDatabricksCli,
},
wantErr: "multiple Databricks profiles match workspace ID 123456789: prod and workspace. Remove duplicate workspace_id entries before using Docker credential helper",
wantErr: "multiple Databricks profiles match workspace ID 123456789: prod and workspace. Docker credential helper requires exactly one profile per workspace. Remove the duplicate profile with: databricks auth logout --profile <profile-name> --delete",
},
}

Expand Down Expand Up @@ -204,7 +204,7 @@ func TestProfileForRegistry(t *testing.T) {
{
name: "duplicate workspace ID",
profiles: profile.Profiles{workspaceProfile("prod"), workspaceProfile("dev")},
wantErr: "multiple Databricks profiles match workspace ID 123456789: prod and dev. Remove duplicate workspace_id entries before using Docker credential helper",
wantErr: "multiple Databricks profiles match workspace ID 123456789: prod and dev. Docker credential helper requires exactly one profile per workspace. Remove the duplicate profile with: databricks auth logout --profile <profile-name> --delete",
},
{
name: "ignores unsupported duplicate",
Expand Down
Loading