Skip to content

[BUG]: no null check for product_info if _product_info not present in the workspaceClient config #980

Description

@sheeluvikas

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

in the function: _verify_workspace_client
we are retrieving the product_info from the config, and checking if product_info[0] != "dqx", and then if its value is not dqx, then setting _product_info as default dqx.

There may be cases, where the user have not set the product in their config, and it would throw the
TypeError: 'NoneType' object is not subscriptable exception

The user might initialise the WorkspaceClient like this:

ws = WorkspaceClient(
    config=Config(
        host=os.getenv("DATABRICKS_HOST"),
        token=os.getenv("DATABRICKS_TOKEN"),
    ),
)

Expected Behavior

The function should check product_info for None, and if None, then set it as default value

Steps To Reproduce

  1. set the WorkspaceClient like this
ws = WorkspaceClient(
    config=Config(
        host=os.getenv("DATABRICKS_HOST"),
        token=os.getenv("DATABRICKS_TOKEN"),
    ),
)

Cloud

AWS

Operating System

macOS

Relevant log output

File "/databricks/python/lib/python3.12/site-packages/databricks/labs/dqx/engine.py", line 473, in __init__
    super().__init__(workspace_client)
  File "/databricks/python/lib/python3.12/site-packages/databricks/labs/dqx/base.py", line 14, in __init__
    self._workspace_client = self._verify_workspace_client(workspace_client)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/databricks/python/lib/python3.12/site-packages/databricks/labs/dqx/base.py", line 33, in _verify_workspace_client
    if product_info[0] != "dqx":
       ~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions