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

During sync export getting http error 400 Client Error: Bad Request for url: https://adb-*.11.azuredatabricks.net/api/2.0/workspace/get-status?path=%5CShared

Open jcbohlin opened this issue 2 years ago • 1 comments

If I use Postman, I receive the same error calling the Databricks API. If I change get-status?path=%5CShared to get-status?path=/Shared or get-status?path=%2fShared api call is successful. Notebook path in the yaml file is /Shared. Any ideas as to why it is converting / to %5C for the call to the api?

Full error text below

2022-05-18 14:03:36 [ERROR] Found exception when running generate. Traceback (most recent call last): File "C:\Python\Python39\databricks-sync\lib\site-packages\databricks_cli\sdk\api_client.py", line 121, in perform_query resp.raise_for_status() File "C:\Python\Python39\databricks-sync\lib\site-packages\requests\models.py", line 960, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://adb-*.11.azuredatabricks.net/api/2.0/workspace/get-status?path=%5CShared

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python\Python39\databricks-sync\lib\site-packages\databricks_sync\sdk\pipeline.py", line 92, in generate async for item in self._generate(): File "C:\Python\Python39\databricks-sync\lib\site-packages\databricks_sync\sdk\generators\notebook.py", line 267, in _generate folder_perms = self.__handle_folder_permissions(folder_path, notebook) File "C:\Python\Python39\databricks-sync\lib\site-packages\databricks_sync\sdk\generators\notebook.py", line 239, in __handle_folder_permissions folder_obj = self.__service.get_status(folder_path) File "C:\Python\Python39\databricks-sync\lib\site-packages\databricks_cli\sdk\service.py", line 570, in get_status return self.client.perform_query('GET', '/workspace/get-status', data=_data, headers=headers) File "C:\Python\Python39\databricks-sync\lib\site-packages\databricks_cli\sdk\api_client.py", line 129, in perform_query raise requests.exceptions.HTTPError(message, response=e.response) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://adb-*.11.azuredatabricks.net/api/2.0/workspace/get-status?path=%5CShared Response from server: { 'error_code': 'INVALID_PARAMETER_VALUE', 'message': "Path (\Shared) doesn't start with '/'"}

jcbohlin avatar May 18 '22 19:05 jcbohlin

hey @jcbohlin i think i discovered the issue. Its the use of Pathlib Path object rather than PosixPath for exporting notebooks and dbfs files. The Path object uses the underlying file path syntax (which in a windows machine its \ instead of /). I will test this on a windows machine after making the patch. In the interim if you can try to run this on a Databricks notebook or a *nix type environment. i.e azure cloud shell, etc.

stikkireddy avatar May 24 '22 18:05 stikkireddy