Skip to content

fix(storage3): Handle None for non-existent signed URLs#1456

Closed
NafeesMadni wants to merge 1 commit intosupabase:mainfrom
NafeesMadni:fix/storage-signed-url-validation
Closed

fix(storage3): Handle None for non-existent signed URLs#1456
NafeesMadni wants to merge 1 commit intosupabase:mainfrom
NafeesMadni:fix/storage-signed-url-validation

Conversation

@NafeesMadni
Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The create_signed_urls function raises a pydantic_core._pydantic_core.ValidationError when attempting to generate signed URLs for files that do not exist in a Supabase storage bucket. This occurs because the Supabase API returns null for the signedURL field for non-existent files, but the SDK's SignedUrlsJsonItem Pydantic model expects a string.

Relevant issue: #1455

What is the new behavior?

This PR updates the SignedUrlsJsonItem Pydantic model to correctly mark the signedURL field as Optional[str]. Additionally, the create_signed_urls methods in both the asynchronous and synchronous file API implementations have been modified to gracefully handle None values for signedURL from the API response.

Now, if a requested file does not exist, the corresponding entry in the CreateSignedUrlResponse list will correctly reflect None for signedURL and signedUrl, without causing a validation error.

Additional context

This fix enhances the robustness of the storage client, preventing crashes when querying for signed URLs of potentially non-existent files. Users can now safely request signed URLs for a list of files, even if some are missing, without the application crashing due to Pydantic validation failures.

@NafeesMadni NafeesMadni changed the title fix(storage): Handle None for non-existent signed URLs fix(storage3): Handle None for non-existent signed URLs Apr 14, 2026
@o-santi
Copy link
Copy Markdown
Contributor

o-santi commented Apr 15, 2026

This PR also needs to fix the tests and some annotations in order to keep make mypy from not throwing an error.

I'll close it in favor of #1461, where I've applied a very similar fix to it, while keeping the types correct.

@o-santi o-santi closed this Apr 15, 2026
@NafeesMadni
Copy link
Copy Markdown
Author

NafeesMadni commented Apr 15, 2026

@o-santi Thank you for the feedback! I'm glad the logic was on the right track. I really appreciate you pointing out the mypy requirements. I’ll take a look at #1461 to see how you handled the annotations so I can keep that in mind for future PRs. Happy to see the fix getting merged!

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.

2 participants