Skip to content

Commit 2d6d54f

Browse files
committed
Prompt for workspace ID when workspace list fails
When `databricks auth login` cannot fetch the workspace list (e.g. when the user has no account-level permissions), instead of silently continuing without a workspace, prompt the user to manually enter a workspace ID. Empty input skips workspace selection as before. Co-authored-by: Isaac
1 parent e5c1351 commit 2d6d54f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

cmd/auth/login.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@ func promptForWorkspaceSelection(ctx context.Context, authArguments *auth.AuthAr
725725

726726
workspaces, err := a.Workspaces.List(ctx)
727727
if err != nil {
728-
return "", err
728+
log.Warnf(ctx, "Failed to load workspaces (this can happen if the user has no account-level access): %v", err)
729+
return promptForWorkspaceID(ctx)
729730
}
730731

731732
if len(workspaces) == 0 {
@@ -764,6 +765,19 @@ func promptForWorkspaceSelection(ctx context.Context, authArguments *auth.AuthAr
764765
return selected, nil
765766
}
766767

768+
// promptForWorkspaceID asks the user to manually enter a workspace ID.
769+
// Returns empty string if the user provides no input.
770+
func promptForWorkspaceID(ctx context.Context) (string, error) {
771+
prompt := cmdio.Prompt(ctx)
772+
prompt.Label = "Enter workspace ID (empty to skip)"
773+
prompt.AllowEdit = true
774+
result, err := prompt.Run()
775+
if err != nil {
776+
return "", err
777+
}
778+
return strings.TrimSpace(result), nil
779+
}
780+
767781
// getBrowserFunc returns a function that opens the given URL in the browser.
768782
// It respects the BROWSER environment variable:
769783
// - empty string: uses the default browser

0 commit comments

Comments
 (0)