Repository navigation
Description
Describe the Bug
Creating a document in an upload collection fails with a 500 ("An unknown error has occurred" in the admin) when both of these are true:
- the storage adapter's
handleUploadreturns metadata such as a newfilename.@payloadcms/storage-vercel-blobdoes this whenaddRandomSuffix: true. - the editor sets a focal point before the first save, so the admin sends
?uploadEdits[focalPoint][x]=…&[y]=….
Server log:
There was an error while uploading files corresponding to the collection media with filename IMG_9210 2.jpeg:
There was a problem while uploading the file. Failed to fetch file from https://<store>.public.blob.vercel-storage.com/IMG_9210%202.jpeg
at hooks.afterChange.adapter …
Cause
In plugin-cloud-storage/src/hooks/afterChange.ts, when handleUpload returns metadata, the hook stores it with a nested req.payload.update({ …, req }) on the same req. Before that call it clears req.file and req.payloadUploadSizes, but leaves req.query.uploadEdits in place.
Inside the nested update, generateFileData → parseUploadEditsFromReqOrIncomingData reads req.query.uploadEdits.focalPoint again. That value came from the query string, so x and y are strings ("37"). shouldReupload compares them strictly with the stored numbers (37), finds them unequal, and treats it as a focal-point edit. It then calls getExternalFile on originalDoc.url, which still points at the pre-suffix filename. That object doesn't exist, so the fetch 404s, the error is thrown, and the create rolls back.
Dragging the file in without setting a focal point works, because no uploadEdits is sent.
Suggested fix (either one works)
- In
afterChange.ts, also clear the consumed edits before the nested update, next toreq.file = undefined:if (req.query) delete req.query.uploadEdits - In
generateFileData.ts, convert to numbers inshouldReupload(Number(uploadEdits.focalPoint.x) === fileData.focalX), so query-string values compare correctly.
Workaround we shipped: a collection beforeOperation hook that deletes req.query.uploadEdits when operation === 'update' && req.context?.skipCloudStorage.
Link to the code that reproduces this issue
Our project repo is private, but the Local API snippet below reproduces it in any project with the Vercel Blob adapter configured with addRandomSuffix: true. Happy to put together a standalone repro repo if that would help.
Reproduction Steps
- Configure
vercelBlobStorage({ collections: { media: true }, addRandomSuffix: true, token })on an upload collection withfocalPoint: true(the default). - In the admin, create a new media doc, choose a file, and move the focal point away from the center.
- Save. The request returns a 500 and the server logs
Failed to fetch file from …/<unsuffixed filename>.
The same thing happens through the Local API:
await payload.create({
collection: 'media',
data: {},
file: { data, mimetype: 'image/jpeg', name: 'test image.jpeg', size: data.length },
req: { query: { uploadEdits: { focalPoint: { x: '37', y: '62' } } } },
})With numeric x/y equal to the stored values, it succeeds.
Which area(s) are affected?
plugin: cloud-storage, area: uploads
Environment Info
payload: 3.90.2 (code unchanged in plugin-cloud-storage 3.91.0)
@payloadcms/storage-vercel-blob: 3.90.2
@vercel/blob: 2.3.1
next: 16.3.6
node: 24
db: @payloadcms/db-postgres
Activity
AmineBenzaazaa commentedon Oct 16, 2026
Thanks for the detailed write-up. I'll open a PR that drops
uploadEditsfrom the query for the nested metadata update (same as the managed-storage branch of that hook already does), with a unit test.fix(storage-vercel-blob): keep image-size filenames separate with add…