Skip to content

storage-vercel-blob: crop / image edit / file replace always 500s — @vercel/blob v2 needs allowOverwrite: true #17378

Closed

Description

@mishery97

Describe the Bug

Since @payloadcms/storage-vercel-blob moved its @vercel/blob dependency from 0.22.3 to 2.3.1, every media operation that replaces an existing file fails: cropping, any image-editor save, and manually replacing a file on an existing upload doc. New uploads still work, which makes the regression easy to miss.

The admin shows a generic "Something went wrong."; the server throws:

Vercel Blob: This blob already exists, use `allowOverwrite: true` if you want to overwrite it. Or `addRandomSuffix: true` to generate a unique filename.

Root cause: @vercel/blob v2 changed put() to refuse overwriting an existing key unless allowOverwrite: true is passed (in 0.x, overwrite was the default). The adapter's uploadFile never passes it:

// dist/uploadFile.js
const result = await put(fileKey, buffer, {
  access,
  addRandomSuffix,
  cacheControlMaxAge,
  contentType: mimeType,
  token,
})

With addRandomSuffix: false (the default), a crop rewrites the same file key, so it collides by construction — the failure is deterministic, not intermittent.

The client-uploads token route (getClientUploadRoute.js → onBeforeGenerateToken) has the same gap: the token payload doesn't include allowOverwrite, so a direct-to-blob replacement with an unchanged filename fails the same way.

Payload's file-replacing operations are written on the assumption that a storage adapter can overwrite in place (crop fetches the stored file, transforms it, and re-puts it under the same key), so the adapter needs to restore the old semantics:

const result = await put(fileKey, buffer, {
  access,
  addRandomSuffix,
  allowOverwrite: true, // v2 default is false; Payload replaces files in place
  cacheControlMaxAge,
  contentType: mimeType,
  token,
})

(and allowOverwrite: true in the onBeforeGenerateToken return for client uploads).

Verified on a production Vercel deployment and in local dev — same deterministic 500 in both. Patching the two call sites with allowOverwrite: true (via pnpm patch) fixes crop/edit/replace with no side effects, and keeps addRandomSuffix: false filenames stable (switching addRandomSuffix on is not a workaround for existing sites — it changes every URL).

To Reproduce

  1. Fresh Payload project with vercelBlobStorage({ collections: { media: true }, token }) — addRandomSuffix left at its default (false).
  2. Upload any image to the media collection (works).
  3. Open the doc, use Crop Image (any crop), save.
  4. Save fails with a 500; the server logs the Vercel Blob: This blob already exists… error from put() called in storage-vercel-blob's uploadFile, invoked from plugin-cloud-storage's afterChange hook.

Payload Version

3.86.0 (@payloadcms/storage-vercel-blob 3.86.0, resolving @vercel/blob 2.3.1)

Adapters and Plugins

storage-vercel-blob, plugin-cloud-storage

Activity

  1. added a commit that references this issue on Jul 22, 2026
    0409a0f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions