Skip to content

fix(storage): use exc.response.text instead of resp.text in error handling - #1568

Open
Samearth17 wants to merge 1 commit into
supabase:mainfrom
Samearth17:fix/storage-error-handling
Open

fix(storage): use exc.response.text instead of resp.text in error handling#1568
Samearth17 wants to merge 1 commit into
supabase:mainfrom
Samearth17:fix/storage-error-handling

Conversation

@Samearth17

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When an HTTP error occurs in the storage API and the response body cannot be parsed into the expected JSON keys (message, error, statusCode), a KeyError is caught. However, the fallback error message attempts to access resp.text. Because resp is the result of exc.response.json() (a Python dictionary), dictionaries do not have a .text attribute. This triggers an AttributeError that completely hides the original API/storage error from the user.

Issue: #1563

What is the new behavior?

This PR updates the error handler to correctly reference exc.response.text (the raw httpx response object) instead of resp.text. This ensures that when JSON parsing fails, the raw text of the HTTP error is properly surfaced to the developer.

I applied this fix to both AsyncBucketActionsMixin and SyncBucketActionsMixin.

Additional context

None

@Samearth17
Samearth17 requested review from a team and o-santi as code owners August 9, 2026 00:00
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