Fix bug where the account or workspace client could be `nil` (#1020)

## Changes

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.

## Tests

Manually confirmed this fixes the linked issue. The CLI now correctly
returns an error when the client cannot be constructed.

The issue was reproducible using a `.databrickscfg` with a single,
incorrectly configured profile.
This commit is contained in:
Pieter Noordhuis 2023-11-29 14:29:17 +01:00 committed by GitHub
parent 833746cbdd
commit deb062c489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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 {