Skip to content

Improve the CLI UX when the workspace client can't be initialised due to an authentication issue #246

@asnare

Description

@asnare

When using the CLI functionality, commands can request have a workspace client injected. At present (0.11.0) when initialised, the client authenticates against the configured workspace. If this fails for some reason an error is raised and the backtrace is logged. Although the reason for the error can be found within the backtrace it would be much better to handle this and:

  1. Inform the user of the reason for the failure;
  2. Give instructions on how they can resolve it.

An example backtrace looks like this:

Traceback (most recent call last):
  File "/Users/**REDACTED**/.databricks/labs/lakebridge/state/venv/lib/python3.10/site-packages/databricks/labs/blueprint/cli.py", line 107, in _route
    kwargs["w"] = self._workspace_client()
  File "/Users/**REDACTED**/.databricks/labs/lakebridge/state/venv/lib/python3.10/site-packages/databricks/labs/blueprint/cli.py", line 128, in _workspace_client
    return WorkspaceClient(
  File "/Users/**REDACTED**/.databricks/labs/lakebridge/state/venv/lib/python3.10/site-packages/databricks/sdk/__init__.py", line 177, in __init__
    config = client.Config(
  File "/Users/**REDACTED**/.databricks/labs/lakebridge/state/venv/lib/python3.10/site-packages/databricks/sdk/config.py", line 189, in __init__
    raise ValueError(message) from e
ValueError: default auth: databricks-cli: cannot get access token: Error: A new access token could not be retrieved because the refresh token is invalid. To reauthenticate, run the following command:
  $ databricks auth login --host https://**REDACTED**.azuredatabricks.net. Config: host=https://**REDACTED**.azuredatabricks.net, auth_type=databricks-cli. Env: DATABRICKS_HOST, DATABRICKS_AUTH_TYPE

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions