From 91e9cb6ffda7d6efdfa514535bf6568cc1f18f69 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Tue, 3 Jun 2025 11:26:37 +0200 Subject: [PATCH 1/2] Use SDK constant to check if default auth cannot be configured --- cmd/root/auth.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/cmd/root/auth.go b/cmd/root/auth.go index 01e79959b3..c22bc9d686 100644 --- a/cmd/root/auth.go +++ b/cmd/root/auth.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "net/http" - "strings" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdctx" @@ -33,20 +32,6 @@ func (e ErrNoAccountProfiles) Error() string { return e.path + " does not contain account profiles" } -func isCannotConfigureAuth(err error) bool { - // As of SDK v0.70.0, this constant was removed. - // - // return errors.Is(err, config.ErrCannotConfigureAuth) - // - // The prefix check is based on this: - // - // https://github.com/databricks/databricks-sdk-go/commit/ef3a65c6ee8f0de253ce6f554e6d905d6a5fdc85#diff-83d1fd7f94efd3481cd11ebab8065cc81e18ef0d8776097c29b8a183a20df52fR86 - return strings.Contains(err.Error(), "cannot configure default credentials, ") -} - -// Referenced by cmd/labs/project/entrypoint.go. -var ErrCannotConfigureAuth = errors.New("cannot configure default credentials, please check https://docs.databricks.com/en/dev-tools/auth.html#databricks-client-unified-authentication to configure credentials for your preferred authentication method.") - func initProfileFlag(cmd *cobra.Command) { cmd.PersistentFlags().StringP("profile", "p", "", "~/.databrickscfg profile") cmd.RegisterFlagCompletionFunc("profile", profile.ProfileCompletion) @@ -73,7 +58,7 @@ func accountClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt // Prompt to select a profile if the current configuration is not an account client. prompt = prompt || errors.Is(err, databricks.ErrNotAccountClient) // Prompt to select a profile if the current configuration doesn't resolve to a credential provider. - prompt = prompt || isCannotConfigureAuth(err) + prompt = prompt || errors.Is(err, config.ErrCannotConfigureDefault) } if !prompt { @@ -173,7 +158,7 @@ func workspaceClientOrPrompt(ctx context.Context, cfg *config.Config, allowPromp // Prompt to select a profile if the current configuration is not a workspace client. prompt = prompt || errors.Is(err, databricks.ErrNotWorkspaceClient) // Prompt to select a profile if the current configuration doesn't resolve to a credential provider. - prompt = prompt || isCannotConfigureAuth(err) + prompt = prompt || errors.Is(err, config.ErrCannotConfigureDefault) } if !prompt { From eeaf224eb27b03b027f3fe6f1c1ccc9750afc3f9 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Tue, 3 Jun 2025 11:42:24 +0200 Subject: [PATCH 2/2] Update labs entrypoint --- cmd/labs/project/entrypoint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/labs/project/entrypoint.go b/cmd/labs/project/entrypoint.go index af7c16ddec..760520ebc6 100644 --- a/cmd/labs/project/entrypoint.go +++ b/cmd/labs/project/entrypoint.go @@ -253,7 +253,7 @@ func (e *Entrypoint) validLogin(cmd *cobra.Command) (*config.Config, error) { isACC := cfg.IsAccountClient() if e.IsAccountLevel && cfg.Profile == "" { if !cmdio.IsPromptSupported(ctx) { - return nil, root.ErrCannotConfigureAuth + return nil, config.ErrCannotConfigureDefault } replaceCfg, err := e.envAwareConfig(ctx) if err != nil {