Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] Improper sanitization/encoding of file paths #586

Closed
dakinggg opened this issue Mar 16, 2024 · 1 comment · May be fixed by #592
Closed

[ISSUE] Improper sanitization/encoding of file paths #586

dakinggg opened this issue Mar 16, 2024 · 1 comment · May be fixed by #592
Assignees

Comments

@dakinggg
Copy link

dakinggg commented Mar 16, 2024

Description
if I make a download request for a file with a question mark in it using WorkspaceClient().files.download(...) , I get

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/composer/utils/object_store/uc_object_store.py", line 179, in download_object
    contents = self.client.files.download(self._get_object_path(object_name)).contents
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/databricks/sdk/service/files.py", line 534, in download
    res = self._api.do('GET', f'/api/2.0/fs/files/{file_path}', headers=headers, raw=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/databricks/sdk/core.py", line 127, in do
    return retryable(self._perform)(method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/databricks/sdk/retries.py", line 50, in wrapper
    raise err
  File "/usr/lib/python3/dist-packages/databricks/sdk/retries.py", line 29, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/databricks/sdk/core.py", line 220, in _perform
    raise self._make_nicer_error(response=response, **payload) from None
databricks.sdk.errors.mapping.BadRequest: Unexpected query parameters: <part of filename after the question mark>.

Similarly, files with a # sign in them simply return a file not found.

Reproduction
Just make a file with the offending character and then try to download it with the sdk.

Expected behavior
All valid filenames can be downloaded using the sdk.

Is it a regression?
No

@mgyucht
Copy link
Contributor

mgyucht commented Apr 4, 2024

@dakinggg this was addressed in #596.

@mgyucht mgyucht closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants