Repository navigation
Prompt for the host instead of failing when device code login has none #7179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
12f1366
faf6adc
f0568c9
b21c6ce
ffcd8b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,9 +225,15 @@ a new profile is created. | |
| // the user re-login to an existing profile, create a new one, or enter | ||
| // a host URL. With no profiles configured the picker still shows the | ||
| // two action entries so the user can choose between web-based discovery | ||
| // (Create a new profile) and a manual host URL. | ||
| // (Create a new profile) and a manual host URL. Device code login skips | ||
| // discovery, so for it "Create a new profile" prompts for the host after | ||
| // the profile name. | ||
| if profileName == "" && authArguments.Host == "" && len(args) == 0 && cmdio.IsPromptSupported(ctx) { | ||
| allProfiles, err := profile.DefaultProfiler.LoadProfiles(ctx, profile.MatchAllProfiles) | ||
| matchProfiles := profile.MatchAllProfiles | ||
| if useDeviceCode { | ||
| matchProfiles = matchDeviceCodeProfiles | ||
| } | ||
| allProfiles, err := profile.DefaultProfiler.LoadProfiles(ctx, matchProfiles) | ||
| if err != nil && !errors.Is(err, profile.ErrNoConfiguration) { | ||
| return err | ||
| } | ||
|
|
@@ -306,11 +312,10 @@ a new profile is created. | |
| } | ||
|
|
||
| // If no host is available from any source, use the discovery flow | ||
| // via login.databricks.com. | ||
| if shouldUseDiscovery(authArguments.Host, args, existingProfile) { | ||
| if useDeviceCode { | ||
| return errDeviceCodeNeedsHost | ||
| } | ||
| // via login.databricks.com. Discovery opens a browser on this machine, | ||
| // and device code login is meant for machines without one, so it skips | ||
| // discovery and setHost resolves the host instead. | ||
| if !useDeviceCode && shouldUseDiscovery(authArguments.Host, args, existingProfile) { | ||
| if err := validateDiscoveryFlagCompatibility(cmd); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -332,11 +337,10 @@ a new profile is created. | |
| return err | ||
| } | ||
| // Check the host once it is resolved, before setAccountID prompts for | ||
| // an account ID for account and unified hosts. | ||
| if useDeviceCode { | ||
| if err := validateDeviceCodeHost(authArguments); err != nil { | ||
| return err | ||
| } | ||
| // an account ID for account and unified hosts. A workspace without | ||
| // device code login enabled is rejected later by DeviceCodeChallenge. | ||
| if useDeviceCode && !isDeviceCodeSupportedForHost(authArguments.Host, authArguments.DiscoveryURL) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With discovery skipped,
Picker → "Enter a host URL manually" → empty input hits the same path, and the user gets the profile name prompt followed by a second host prompt. Before this PR, I think the simplest fix is to reject empty input in |
||
| return errDeviceCodeWorkspaceOnly | ||
| } | ||
| err = setAccountID(ctx, existingProfile, authArguments) | ||
| if err != nil { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional, and mostly unrelated to this PR: after "Create a new profile" no host is known yet, so the name prompt suggests
DEFAULT, and pressing Enter loads the existingDEFAULTprofile if there is one. If that's an account profile the picker just hid, the user gets--use-device-code is only supported for workspace hostsfor a profile they didn't pick. If it's a workspace profile, login reuses its host instead of prompting as this comment describes. Browser login reusesDEFAULTthe same way, so fine to leave for a follow-up.