supabase-py icon indicating copy to clipboard operation
supabase-py copied to clipboard

Storage client blows up on 400s

Open jezell opened this issue 10 months ago • 3 comments

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 avatar Jan 30 '25 21:01 jezell

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

silentworks avatar Jan 30 '25 23:01 silentworks

Can not reproduce.

juancarlospaco avatar Jan 30 '25 23:01 juancarlospaco

Hi! I'd love to work on this issue. Can I take it?

P3st83 avatar Feb 25 '25 18:02 P3st83

Cannot reproduce. The actual error is that it is trying to use an undefined variable:

  NameError: name 'resp' is not defined

But this is not the case as resp is clearly defined, in _request.

o-santi avatar Oct 01 '25 17:10 o-santi