fix(storage): handle null signedURL in createSignedUrls response#1356
Open
fix(storage): handle null signedURL in createSignedUrls response#1356
Conversation
When a requested path does not exist, the Storage API returns
"signedURL": null for that item. Previously, createSignedUrls silently
produced broken URLs like "${storageUrl}null" and createSignedUrl
returned a similarly malformed string.
Changes:
- SignedUrl.signedUrl is now String? (nullable); callers should check
for null to detect missing paths
- SignedUrl gains an optional `error` field populated from the
per-item error returned by the API
- createSignedUrl throws StorageException when the API returns a null
signedURL, consistent with the createSignedUploadUrl pattern
- createSignedUrls sets signedUrl to null and populates error for
items where the server returned no signed URL
Closes: SDK-862
Related: SDK-851 (Swift), SDK-842 (Python)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Vinzent03
reviewed
Apr 16, 2026
Collaborator
Vinzent03
left a comment
There was a problem hiding this comment.
While yeah the previous behavior was not correct this is really a breaking change for everybody using the method for multiple urls. Their code will not compile as Dart is sound. So I would not release this. Either way I wanted to start working now on v3, so we could delay it for v3.
| final signedUrlPath = e['signedURL'] as String?; | ||
| return SignedUrl( | ||
| // Prevents exceptions being thrown when null value is returned | ||
| // https://github.com/supabase/storage-api/issues/353 |
Collaborator
There was a problem hiding this comment.
I think we should either keep this comment or remove the null catch for the path field. Or is that also null if signedURL is null?
| path: e['path'] ?? '', | ||
| signedUrl: '$url${e['signedURL']}', | ||
| signedUrl: signedUrlPath != null ? '$url$signedUrlPath' : null, | ||
| error: e['error'] as String?, |
Collaborator
There was a problem hiding this comment.
Does the error field only exists for requesting multiple urls or would that also exist for the case above of a single url request?
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.
Summary
When a requested path does not exist, the Storage API returns
"signedURL": nullfor that item. The Flutter SDK was silently producing broken URLs like"${storageUrl}null"with no way for callers to detect the issue. This mirrors the fix applied to the Swift SDK in supabase/supabase-swift#958.Changes
types.dart:SignedUrl.signedUrlis nowString?(nullable); added optionalerror: String?field populated from the per-item server errorstorage_file_api.dart:createSignedUrlthrowsStorageExceptionwhen the API returns null (consistent withcreateSignedUploadUrl);createSignedUrlssetssignedUrlto null and populateserrorfor missing-path itemstest/basic_test.dart: Added tests for both null-signedURL scenarios; updated existingcreateSignedUrltest to assert the URL suffixRoot Cause
storage_file_api.dart:402—'$url${e['signedURL']}'with a null value produces the literal string"${url}null"storage_file_api.dart:370— same issue in the single-URL varianttypes.dart:250—signedUrlwas non-nullable, making it impossible for callers to detect a missing pathTesting
Reproduction Tests
createSignedUrl throws StorageException when signedURL is null— previously returned broken URL, now throwscreateSignedUrls returns null signedUrl and error for missing path— previously returned broken URL, now returnssignedUrl: null, error: 'not_found'Test Results
All 37 unit tests pass. Integration tests (
client_test.dart) require a live storage server and are unaffected by this change.Breaking Changes
SignedUrl.signedUrlchanges fromStringtoString?. Callers that use this field without a null check will need to be updated. This is intentional — the previous non-null return was a false guarantee.Acceptance Criteria
createSignedUrlsdoes not return items withsignedUrl == "${storageUrl}null"createSignedUrlthrowsStorageExceptionwhen the API returns null signedURLLinear Issue
Closes: SDK-862
Related: SDK-851 (Swift), SDK-842 (Python)
🤖 Generated with Claude Code
/take