fix(storage): use toString() for statusCode to handle non-string type…#1323
Open
mitchkoko wants to merge 1 commit intosupabase:mainfrom
Open
fix(storage): use toString() for statusCode to handle non-string type…#1323mitchkoko wants to merge 1 commit intosupabase:mainfrom
mitchkoko wants to merge 1 commit intosupabase:mainfrom
Conversation
…s StorageException.fromJson used 'as String?' to cast statusCode, which returns null when the server sends statusCode as an integer. Changed to .toString() so the statusCode from the JSON body is correctly preserved regardless of type. Fixes supabase#1312
Contributor
|
Hey @mitchkoko, I understand the change and it makes sense, but tests are failing. The issue arises because the However, it doesn't use This happens because, even though the JSON response contains Please revert the test changes, but keep the Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…s StorageException.fromJson used 'as String?' to cast statusCode, which
returns null when the server sends statusCode as an integer. Changed to
.toString() so the statusCode from the JSON body is correctly preserved
regardless of type.
Fixes #1312
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
StorageException.fromJsonusesas String?to castjson['statusCode'], which silently returnsnullwhen the server sendsstatusCodeas an integer (e.g.,404instead of"404"). This causes the exception to fall back to the HTTP status code, which can be different from the actual storage error code.For example, a "not found" error returns
statusCode: 400on the exception object, while the JSON body contains404.What is the new behavior?
Uses
.toString()instead ofas String?, which correctly converts thestatusCoderegardless of whether the server sends it as a string or integer. The exception now consistently reflects the status code from the JSON response body.Additional context
Updated test expectations from
'400'to'404'in three places where tests were asserting the old (incorrect) status code for "file not found" scenarios.