Skip to content

fix(storage): preserve malformed error response body - #1582

Closed
cookiestone12 wants to merge 1 commit into
supabase:mainfrom
cookiestone12:codex/fix-storage-error-fallback-1563
Closed

cookiestone12 wants to merge 1 commit into
supabase:mainfrom
cookiestone12:codex/fix-storage-error-fallback-1563

Conversation

@cookiestone12

Copy link
Copy Markdown

Summary

  • Preserve the raw Storage API response body when its JSON omits required error fields.
  • Add synchronous and asynchronous regression coverage.

Problem / root cause

When a non-2xx Storage response lacked message, error, or statusCode, the fallback attempted to read .text from the parsed JSON dictionary. That raised AttributeError and hid the server response.

Solution

Read the raw body from exc.response.text in both request implementations and assert the resulting StorageApiError preserves it.

Testing performed

  • Added sync and async mocked regression tests for {"code":"TooLarge"}.
  • Verified the exact original request handlers raise AttributeError and the patched handlers raise StorageApiError with the raw body, fallback code, and status.
  • python3 -m py_compile and git diff --check passed.
  • Repository-native pytest, ruff, and mypy could not run locally because this environment lacks uv/test dependencies and cannot reach PyPI.

Closes #1563.

@grdsdev

grdsdev commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for this, and for including a regression test. Closing on #1577, which additionally fixes bucket.py (same bug, no guard at all there) and handles non-JSON error bodies, which this one leaves raising JSONDecodeError.

@grdsdev grdsdev closed this Sep 2, 2026
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 this pull request may close these issues.

storage3: AttributeError masks the real error when a storage error body lacks message/error/statusCode

2 participants