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

Storage client blows up on 400s #1048

Open
jezell opened this issue Jan 30, 2025 · 2 comments
Open

Storage client blows up on 400s #1048

jezell opened this issue Jan 30, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@jezell
Copy link

jezell commented Jan 30, 2025

Bug report

  • [ x] I confirm this is a bug with Supabase, not with my own application.
  • [xx ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

If any of the storage APIs returns a 400 error, the storage client doesn't properly handle the response and blows up trying to parse it as JSON.

To Reproduce

Do something that would return a 400 from the storage api (often happens with uploads when given incorrect parameters for example).

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "supabase_storage_provider.py", line 39, in aclose
    await (await self.provider.client).storage.from_(self.provider.bucket_name).upload(
  File "venv/lib/python3.12/site-packages/storage3/_async/file_api.py", line 520, in upload
    return await self._upload_or_update("POST", path, file, file_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/storage3/_async/file_api.py", line 493, in _upload_or_update
    response = await self._request(
               ^^^^^^^^^^^^^^^^^^^^
  File "venv/lib/python3.12/site-packages/storage3/_async/file_api.py", line 54, in _request
    raise StorageApiError(resp["message"], resp["error"], resp["statusCode"])
                          ^^^^
  NameError: name 'resp' is not defined

Expected behavior

expected result is an exception with a description of the problem, not blowing up on parsing JSON

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

Add any other context about the problem here.

@jezell jezell added the bug Something isn't working label Jan 30, 2025
@silentworks
Copy link
Contributor

Please provide reproducible steps. Saying Do something that would return a 400 from the storage api is not reproducible steps.

@juancarlospaco
Copy link
Contributor

Can not reproduce.

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
Development

No branches or pull requests

3 participants