Skip to content

storage-vercel-blob with addRandomSuffix: a create or a file replacement answers with a url that gives 404 #18384

Open

Description

@franknoel

Describe the Bug

With @payloadcms/storage-vercel-blob and addRandomSuffix: true, the answer of a create, and of a file replacement, carries the new filename with the url of the name before the suffix:

filename: photo-D2Ap3L30Q4GueEBLM5kWlAYEErlBZB.jpg
url:      https://<store>.public.blob.vercel-storage.com/photo.jpg

No file exists at that URL, it gives 404. The database is right, and a later read of the document gives the right url. So a client that uses the answer of its own request gets a dead link.

The collection has no image sizes. #9589 reports missing image sizes with the same option, and a comment there names the same cause. This report shows that the cause also breaks a collection with no image sizes, and it comes with a reproduction.

The cause, in two steps:

  1. In packages/storage-vercel-blob/src/adapter.ts, handleUpload sets the new name on the document it was given, and returns the whole document. That document already holds a url built from the first name.

    if (result.filename) {
      data.filename = result.filename
    }
    
    return data
  2. In packages/plugin-cloud-storage/src/hooks/afterChange.ts, the hook merges what handleUpload returns, saves it, and returns { ...doc, ...uploadMetadata }. The answer then has the new filename and the old url.

Expected: the answer carries the url of the stored file, the one a later read gives.

Why a site turns addRandomSuffix on: without it, a replaced or deleted file frees its name, and the next file with that name lands at the old URL, which browsers and the CDN may have cached for a long time. Payload checks a new name against the database only.

Link to the code that reproduces this issue

https://github.com/franknoel/payload-blob-random-suffix

Reproduction Steps

  1. Clone the repository. cp .env.example .env, then fill in DATABASE_URL, PAYLOAD_SECRET and a Vercel Blob BLOB_READ_WRITE_TOKEN of a public store.
  2. pnpm install
  3. pnpm check

The script creates a document with the local API, then replaces its file. Each time, it fetches the url of the answer and the url of a later read:

DEAD  create   answer      HTTP 404  photo-D2Ap3L30Q4GueEBLM5kWlAYEErlBZB.jpg  https://<store>.public.blob.vercel-storage.com/photo.jpg
ok    create   later read  HTTP 200  photo-D2Ap3L30Q4GueEBLM5kWlAYEErlBZB.jpg  https://<store>.public.blob.vercel-storage.com/photo-D2Ap3L30Q4GueEBLM5kWlAYEErlBZB.jpg
DEAD  replace  answer      HTTP 404  photo-LuZRYeK418OOLu6JRa9wUEZUaffBeI.jpg  https://<store>.public.blob.vercel-storage.com/photo.jpg
ok    replace  later read  HTTP 200  photo-LuZRYeK418OOLu6JRa9wUEZUaffBeI.jpg  https://<store>.public.blob.vercel-storage.com/photo-LuZRYeK418OOLu6JRa9wUEZUaffBeI.jpg

The collection has disablePayloadAccessControl: true, so that url is the file's URL in the store and the script can fetch it with no server running.

The same happens over REST: with pnpm dev running, a POST /api/media with fixtures/photo.jpg answers with the new filename and a url that ends with /photo.jpg.

Which area(s) are affected?

plugin: cloud-storage, plugin: storage-*

Environment Info

Binaries:
  Node: 24.21.0
  npm: 11.19.0
  Yarn: 1.22.22
  pnpm: 9.15.9
Relevant Packages:
  payload: 3.90.2
  next: 16.3.3
  @payloadcms/db-mongodb: 3.90.2
  @payloadcms/graphql: 3.90.2
  @payloadcms/next/utilities: 3.90.2
  @payloadcms/plugin-cloud-storage: 3.90.2
  @payloadcms/richtext-lexical: 3.90.2
  @payloadcms/storage-vercel-blob: 3.90.2
  @payloadcms/translations: 3.90.2
  @payloadcms/ui/shared: 3.90.2
  react: 19.2.6
  react-dom: 19.2.6
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.6.0
  Available memory (MB): 32768
  Available CPU cores: 10

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Sep 29, 2026
  2. added
    plugin: cloud-storage
    and removed
    validate-reproduction
    on Sep 29, 2026
  3. removed
    status: needs-triage
    on Oct 1, 2026
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

    Bugplugin: cloud-storage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions