From 592891d19222873839565a85723febb55d88f6a6 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 29 Nov 2023 13:54:30 +0100 Subject: [PATCH 1/2] Fix bug where the account or workspace client could be nil We didn't return the error upon creating a workspace or account client. If there is an error, it must always propagate up the stack. The result of this bug was that we were setting a `nil` account or workspace client, which in turn caused SIGSEGVs. Fixes #913. --- cmd/root/auth.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/root/auth.go b/cmd/root/auth.go index 350cbc65a7..408a58a367 100644 --- a/cmd/root/auth.go +++ b/cmd/root/auth.go @@ -65,7 +65,7 @@ func accountClientOrPrompt(ctx context.Context, cfg *config.Config, allowPrompt return nil, err } } - return a, nil + return a, err } func MustAccountClient(cmd *cobra.Command, args []string) error { @@ -133,7 +133,7 @@ func workspaceClientOrPrompt(ctx context.Context, cfg *config.Config, allowPromp return nil, err } } - return w, nil + return w, err } func MustWorkspaceClient(cmd *cobra.Command, args []string) error { @@ -254,6 +254,9 @@ func WorkspaceClient(ctx context.Context) *databricks.WorkspaceClient { if !ok { panic("cannot get *databricks.WorkspaceClient. Please report it as a bug") } + if w == nil { + panic("workspace client is nil. Please report it as a bug") + } return w } @@ -262,5 +265,8 @@ func AccountClient(ctx context.Context) *databricks.AccountClient { if !ok { panic("cannot get *databricks.AccountClient. Please report it as a bug") } + if a == nil { + panic("account client is nil. Please report it as a bug") + } return a } From d576bf9056a5d81a48614246798c35ee1b724ccf Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 29 Nov 2023 14:17:32 +0100 Subject: [PATCH 2/2] Remove nil checks --- cmd/root/auth.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmd/root/auth.go b/cmd/root/auth.go index 408a58a367..99e9104396 100644 --- a/cmd/root/auth.go +++ b/cmd/root/auth.go @@ -254,9 +254,6 @@ func WorkspaceClient(ctx context.Context) *databricks.WorkspaceClient { if !ok { panic("cannot get *databricks.WorkspaceClient. Please report it as a bug") } - if w == nil { - panic("workspace client is nil. Please report it as a bug") - } return w } @@ -265,8 +262,5 @@ func AccountClient(ctx context.Context) *databricks.AccountClient { if !ok { panic("cannot get *databricks.AccountClient. Please report it as a bug") } - if a == nil { - panic("account client is nil. Please report it as a bug") - } return a }