Skip to content

Fix: handle non-standard and non-JSON error responses without AttributeError - #1577

Open
Vishv07 wants to merge 1 commit into
supabase:mainfrom
Vishv07:fix-storage3-error-parsing
Open

Fix: handle non-standard and non-JSON error responses without AttributeError#1577
Vishv07 wants to merge 1 commit into
supabase:mainfrom
Vishv07:fix-storage3-error-parsing

Conversation

@Vishv07

@Vishv07 Vishv07 commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Fixes an AttributeError in storage3 where non-2xx responses that lack message, error, or statusCode keys in their JSON body (or return non-JSON payloads like HTML 502/504 gateway errors) crashed with 'dict' object has no attribute 'text' or uncaught JSONDecodeError.

Changes

  • In _async/file_api.py, _async/bucket.py, and _sync counterparts:
    • Catch (KeyError, ValueError) when decoding error response JSON.
    • Access exc.response.text instead of resp.text.
    • Pass exc.response.status_code to StorageApiError.
  • Added unit regression tests for missing error keys and non-JSON error responses across test_client.py and test_bucket.py (both async and sync).

Verification

  • All 51 unit tests in src/storage pass.
  • mypy check passes with 0 issues.
  • ruff check and ruff format pass cleanly.

@Vishv07
Vishv07 requested review from a team and o-santi as code owners August 16, 2026 05:06
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.

1 participant