Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storage-vercel-blob): return 404 when file is not found #10327

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

andershermansen
Copy link
Contributor

What

The vercel storage adapter returns a 500 internal server error when a file is not found.
It's expected that it will return 404 when a file is not found.

Why

The head function from vercel blob sdk does not return undefined when a blob is not found, but throws an error as documented here: https://vercel.com/docs/storage/vercel-blob/using-blob-sdk#head

How

Check if exception thrown is of type BlobNotFoundError and return a 404 in that case.

Testing

Note: I have not been able to test this inside payload itself as I'm unable to build a package to test with. I have tested the implementation outside. Is it possible to get a canary build so proper testing with package can be done?

Fixes #10326

@denolfe
Copy link
Member

denolfe commented Jan 3, 2025

Nice one 👍

I've released canary versions for testing: 3.14.1-canary.881311e.

@andershermansen
Copy link
Contributor Author

I've released canary versions for testing: 3.14.1-canary.881311e.

Thanks, works as expected 👍
Returns 404 as it should.

@denolfe denolfe merged commit d68a1ea into payloadcms:main Jan 3, 2025
74 checks passed
@denolfe
Copy link
Member

denolfe commented Jan 3, 2025

Good work on this one, @andershermansen , thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vercel storage adapter returns 500 instead of 404 when file is not found
2 participants