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

exists method throws if file does not exist #333

Closed
jezell opened this issue Jan 10, 2025 · 3 comments · Fixed by #335 · May be fixed by #336
Closed

exists method throws if file does not exist #333

jezell opened this issue Jan 10, 2025 · 3 comments · Fixed by #335 · May be fixed by #336
Assignees
Labels
bug Something isn't working

Comments

@jezell
Copy link

jezell commented Jan 10, 2025

Describe the bug

Exception is thrown when trying to check if file exists

  ^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/storage3/_async/file_api.py", line 53, in _request
    resp = exc.response.json()
  ^^^^^^^^^^^^^^^^^^^

To Reproduce

Check to see if a file exists, which does not actually exist.

Expected behavior

Returns false

It appears that the _request method always calls raise_for_status, which throws if the file does not exist due to the status code, but in this case the body does not contain json, so it fails to parse the json in the except handler and blows up, instead of passing through the original request.

Changing _request to not raise_for_status when method = "HEAD" seems to resolve the issue.

@silentworks
Copy link
Collaborator

Please provide code example of the method you are referring to in your issue. Also note the Python library throws exception rather than return boolean in its code base.

@jezell
Copy link
Author

jezell commented Jan 12, 2025

It certainly shouldn't be throwing this an exception saying it can't parse the request.

Screenshot 2025-01-12 at 9 51 46 AM

This is the method in question, which clearly says it returns a boolean.

Screenshot 2025-01-12 at 9 52 54 AM

@silentworks silentworks self-assigned this Jan 12, 2025
@silentworks
Copy link
Collaborator

Thanks for providing the additional information. I'll take a look into this and get back to you here.

@silentworks silentworks added the bug Something isn't working label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants