Skip to content

auth: highlight default profile and unify pickers across login/logout/switch/token#5218

Merged
simonfaltum merged 3 commits intomainfrom
simonfaltum/auth-default-profile-picker
May 8, 2026
Merged

auth: highlight default profile and unify pickers across login/logout/switch/token#5218
simonfaltum merged 3 commits intomainfrom
simonfaltum/auth-default-profile-picker

Conversation

@simonfaltum
Copy link
Copy Markdown
Member

Why

When users have several profiles in ~/.databrickscfg, the picker shown by databricks auth switch, databricks auth logout, databricks auth token, and databricks auth login doesn't tell them which one is currently the default. Locating the default in a long list, especially when commands try to pre-fill it, is more guesswork than it should be. The four commands also drift in their picker implementations: auth token has a richer picker that lets users create a new profile, while auth login only has a text prompt for the profile name, and auth logout and auth switch have their own slightly different flavors.

Changes

Before: Each auth command had its own picker. None highlighted the default profile. auth login couldn't pick an existing profile from a list.

Now: The four auth commands share two picker shapes:

  • auth switch and auth logout use a profile-only picker
  • auth token and auth login use the same picker plus "Create a new profile" and "Enter a host URL manually" entries

In all four, the default profile (from [__settings__] / default_profile) is moved to the top of the list and tagged [default] (green when highlighted).

Implementation:

  • libs/databrickscfg/profile/select.go: added a Default field to SelectConfig. When set, SelectProfile reorders so the default comes first and exposes IsDefault to templates. Existing callers that pass custom templates are unaffected.
  • cmd/auth/profile_picker.go (new): pickAuthProfile is the auth-package picker. It supports an IncludeExtras option for the "Create new" / "Enter host" entries used by auth login and auth token.
  • cmd/auth/switch.go and cmd/auth/logout.go: switched to pickAuthProfile with no extras and Default set.
  • cmd/auth/token.go: replaced the bespoke picker (promptForProfileSelection, profileSelectItem, profileSelectionResult) with pickAuthProfile (IncludeExtras: true, Default set).
  • cmd/auth/login.go: when the command is interactive and no --profile, --host, or positional argument is provided, show the same picker as auth token. Selecting an existing profile triggers a re-login (OAuth refresh) against that profile's host.

Test plan

  • New unit tests for the ordering helper in libs/databrickscfg/profile/select_test.go and for the picker in cmd/auth/profile_picker_test.go.
  • All existing cmd/auth/... unit tests and acceptance/cmd/auth/... acceptance tests pass.
  • ./task checks, ./task fmt-q, and ./task lint-q are clean.

This pull request and its description were written by Isaac.

…/switch/token

The interactive profile pickers shown by `databricks auth switch`,
`databricks auth logout`, `databricks auth token`, and
`databricks auth login` now mark the default profile with a
"[default]" tag and move it to the top of the list. The pickers used
by login/token are identical (with "Create a new profile" and
"Enter a host URL manually" entries), and the pickers used by
switch/logout share a common implementation.

Co-authored-by: Isaac
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 8, 2026 09:44 — with GitHub Actions Inactive
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 8, 2026 09:44 — with GitHub Actions Inactive
…onfig

- pickAuthProfile gains a SelectedNoun option so logout prints
  "Selected profile" and switch prints "Default profile" while token
  and login keep "Using profile".
- auth login now shows the picker even when no profiles are configured,
  so a first-time user can pick web-based discovery (Create a new
  profile) or a manual host URL from the start. The label adapts to
  "How would you like to log in?" in the empty-config case.

Co-authored-by: Isaac
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 8, 2026 10:33 — with GitHub Actions Inactive
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 8, 2026 10:33 — with GitHub Actions Inactive
Comment thread cmd/auth/login.go
Comment on lines +209 to +214
case profilePickerEnterHost:
host, err := promptForHost(ctx)
if err != nil {
return err
}
authArguments.Host = host
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] Do we want this to fall through to the profile name prompt bellow?

From playing around if I introduce the host of a workspace for which I already have a profile I get asked to input a profile name and it creates a new profile.

Is this what we want or should we have some discovery mechanism where we show the available profiles for that host?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep it simple, and assume you want to create a new profile in this case

Comment on lines +92 to +97
if includeExtras {
items = append(items,
pickerItem{Name: profilePickerCreateNewLabel, IsExtra: true, Extra: profilePickerCreateNew},
pickerItem{Name: profilePickerEnterHostLabel, IsExtra: true, Extra: profilePickerEnterHost},
)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] From the point of view of the semantics of these commands it makes sense to have the extras at the bottom. You call login not a hypothetical create. However, if you actually want to create a profile you have to go though login and if you have multiple accounts you have to go through ALL of them and reach the bottom of the list.

Is this something we should acknowledge but accept or should we move the extra options at the top and then have the profiles bellow?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is ultimately, do we think people are more likely to use databricks auth login to refresh tokens for existing profiles or to create new profiles. My assumption is that the more profiles you have, the less likely you are to want to create new profiles (and also the more advanced a user you would be). So thats why the behavior is how it is right now

Comment thread cmd/auth/token.go
Comment on lines +355 to 356
case profilePickerEnterHost:
// Fall through — setHostAndAccountId will prompt for the host.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question regarding entering host and creating new profiles

…ult-profile-picker

# Conflicts:
#	NEXT_CHANGELOG.md
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 8, 2026 11:40 — with GitHub Actions Inactive
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 8, 2026 11:40 — with GitHub Actions Inactive
@simonfaltum simonfaltum merged commit 83efe60 into main May 8, 2026
22 of 23 checks passed
@simonfaltum simonfaltum deleted the simonfaltum/auth-default-profile-picker branch May 8, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants