You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Image Resizing Fails When addRandomSuffix: true in vercelBlobStorage Configuration #9589
When uploading images in various sizes, only the original image file with its original dimensions is created.
All other image sizes are not generated and remain empty.
This issue occurs only when the addRandomSuffix: true option is enabled in the vercelBlobStorage configuration.
When the addRandomSuffix option is removed, the functionality works as expected.
Add addRandomSuffix: true to the vercelBlobStorage config inside the payload config file.
Then login to the backend, navigate to the media collection and try to upload some image.
Which area(s) are affected? (Select all that apply)
it's been a couple of months but I just had the issue. Using vercel blob, the random suffix gets added to the img url in vercel blob but the url is stored in the db without the suffix, hence they are 404'ing
Encountered this on @payloadcms/[email protected] / @payloadcms/[email protected]. I diffed the relevant files against 3.87.0 (current latest) and they're unchanged, so it should still be present there — though I haven't run it on 3.87.0 to confirm. Here's the mechanism, plus a possible explanation for the earlier non-repro.
Root cause
adapter.js mutates the shared document object on every upload:
handleUpload: async({ data,file: { buffer, filename, mimeType }})=>{constresult=awaituploadFile({ ...,addRandomSuffix, filename, ... })if(result.filename){data.filename=result.filename// `data` is the doc, shared by all files}returndata// returns the whole doc, not a per-file patch}
plugin-cloud-storage's getAfterChangeHook calls that for the original and every image size concurrently, then collapses the results last-write-wins:
Every element of uploadResults is the same object reference, so uploadMetadata.filename is whichever upload resolved last. Two consequences:
The document's top-level filename/url point at one of the resized variants, not the original.
No sizes.*.filename is ever updated with its own random suffix, so every variant URL 404s — those blobs exist under randomized names nothing references, and the true original is orphaned entirely.
A resulting row (source image 1080×1350):
field
stored value
blob
filename
Foo-500x500-<random suffix>.png
200
sizes.thumbnail.filename
Foo-300x375.png
404
sizes.adminThumbnail.filename
Foo-240x300.png
404
original
Foo.png
404
A possible explanation for the non-repro
@PatrikKozak — this may be why it didn't reproduce during triage: the discriminator looks like imageSizes rather than the storage mode. Without imageSizes — or anywhere sharp isn't producing sizes — files has a single entry, so there's no race, data.filename correctly receives the randomized original name, and everything works. Might be worth re-checking whether the collection under test had an imageSizes array.
clientUploads doesn't avoid it — it makes it deterministic
getIncomingFiles sets clientUploadContext only on mainFile; the size entries never get it. So files.filter((file) => !file.clientUploadContext) skips only the original, and the sizes still upload server-side in both modes. Size generation itself is unconditional — generateFileData.js gates it on fileSupportsResize && imageSizes only, and under clientUploads the server re-downloads the blob to rebuild the buffer for sharp.
clientUploads: false — the original is in the race, so it occasionally wins and filename survives.
clientUploads: true — the original is filtered out, so a variant always wins.
Variant URLs are broken either way.
Suggested direction
handleUpload returning the mutated doc is what makes the merge unsafe. Returning a per-file patch — { filename } for the main file, { sizes: { [size]: { filename } } } for a size — and deep-merging would fix both halves. That requires handleUpload to know which size it's handling; getIncomingFiles already knows and could pass it through.
Activity
PatrikKozak commentedon Apr 1, 2025
Hey @mednet-ecrep,
Thanks for your patience here!
Can you confirm if this issue is still happening on your end?
I wasn't able to reproduce it on my initial testings
Crayonan commentedon May 7, 2025
@PatrikKozak
I am also running into this exact problem, when I change the random suffix to false this solved the problem of resizing.
marcosdipaolo commentedon Jul 16, 2025
it's been a couple of months but I just had the issue. Using vercel blob, the random suffix gets added to the img url in vercel blob but the url is stored in the db without the suffix, hence they are 404'ing
donbellamy commentedon Apr 28, 2026
Just confirming this is still an issue. Thanks!
Toti91 commentedon Jul 2, 2026
Still running into this issue.
jmtorres commentedon Jul 31, 2026
Encountered this on
@payloadcms/[email protected]/@payloadcms/[email protected]. I diffed the relevant files against 3.87.0 (current latest) and they're unchanged, so it should still be present there — though I haven't run it on 3.87.0 to confirm. Here's the mechanism, plus a possible explanation for the earlier non-repro.Root cause
adapter.jsmutates the shared document object on every upload:plugin-cloud-storage'sgetAfterChangeHookcalls that for the original and every image size concurrently, then collapses the results last-write-wins:Every element of
uploadResultsis the same object reference, souploadMetadata.filenameis whichever upload resolved last. Two consequences:filename/urlpoint at one of the resized variants, not the original.sizes.*.filenameis ever updated with its own random suffix, so every variant URL 404s — those blobs exist under randomized names nothing references, and the true original is orphaned entirely.A resulting row (source image 1080×1350):
filenameFoo-500x500-<random suffix>.pngsizes.thumbnail.filenameFoo-300x375.pngsizes.adminThumbnail.filenameFoo-240x300.pngFoo.pngA possible explanation for the non-repro
@PatrikKozak — this may be why it didn't reproduce during triage: the discriminator looks like
imageSizesrather than the storage mode. WithoutimageSizes— or anywhere sharp isn't producing sizes —fileshas a single entry, so there's no race,data.filenamecorrectly receives the randomized original name, and everything works. Might be worth re-checking whether the collection under test had animageSizesarray.clientUploadsdoesn't avoid it — it makes it deterministicgetIncomingFilessetsclientUploadContextonly onmainFile; the size entries never get it. Sofiles.filter((file) => !file.clientUploadContext)skips only the original, and the sizes still upload server-side in both modes. Size generation itself is unconditional —generateFileData.jsgates it onfileSupportsResize && imageSizesonly, and underclientUploadsthe server re-downloads the blob to rebuild the buffer for sharp.clientUploads: false— the original is in the race, so it occasionally wins andfilenamesurvives.clientUploads: true— the original is filtered out, so a variant always wins.Variant URLs are broken either way.
Suggested direction
handleUploadreturning the mutated doc is what makes the merge unsafe. Returning a per-file patch —{ filename }for the main file,{ sizes: { [size]: { filename } } }for a size — and deep-merging would fix both halves. That requireshandleUploadto know which size it's handling;getIncomingFilesalready knows and could pass it through.Vercel Blob storageのaddRandomSuffixを無効化(サイズ違いアップロードのURL破損対策)
Vercel Blob storageのaddRandomSuffixを無効化(サイズ違いアップロードのURL破損対策)
fix(storage-vercel-blob): keep image-size filenames separate with add…
github-actions commentedon Oct 27, 2026
🚀 This is included in version v3.92.1
nathanlentz commentedon Oct 29, 2026
Addressed in #18920