databricks-cli icon indicating copy to clipboard operation
databricks-cli copied to clipboard

Python API does not validate host

Open cozos opened this issue 3 years ago • 1 comments

If you forget to put https:// in the host here:

api_client = ApiClient(
  host  = "SOMETHING_WITHOUT_HTTPS://",
  token = os.getenv('DATABRICKS_TOKEN')
)

You'll get this exception as self.url is broken:

requests.exceptions.InvalidSchema: No connection adapters were found for '://None/api/2.0/dbfs/get-status'

cozos avatar Oct 06 '22 11:10 cozos

Thanks for reporting the issue.

The code expects the scheme to be included today but it's reasonable to not require it.

Would you be willing to submit a PR for this?

The code lives here: https://github.com/databricks/databricks-cli/blob/81c26a8c77b377b25663abc201e87163238e3f7d/databricks_cli/sdk/api_client.py#L114-L117

pietern avatar Oct 06 '22 12:10 pietern