Skip to content

UploadThing Storage Plugin - Media Creation Fails with Key Extraction Error #12455

@viniciuslk

Description

@viniciuslk

Describe the Bug

When attempting to create new media files using the UploadThing storage plugin, the system fails with an "unable to extract key from doc" error. This occurs during the initial file upload and creation process in the media collection.

Link to the code that reproduces this issue

https://github.com/viniciuslk/payload-cms-uploadthing-error-reproduction

Reproduction Steps

  1. Set up a Payload CMS project with UploadThing storage plugin
  2. Configure the plugin with the following settings:
uploadthingStorage({
  collections: {
    media: true,
  },
  options: {
    token: process.env.UPLOADTHING_TOKEN,
    acl: 'public-read',
  },
})
  1. Navigate to the admin interface
  2. Go to Media collection
  3. Attempt to upload a new media file
  4. Observe the error in the console

Expected Behavior

The media file should be successfully uploaded and created in the UploadThing storage, with all necessary file transformations (different sizes) being processed correctly.

Actual Behavior

The system throws the following errors during file creation:

[ERROR] Error deleting file: aspect-ratio-9-16-2.jpg - unable to extract key from doc
[ERROR] Error deleting file: aspect-ratio-9-16-2-300x452.jpg - unable to extract key from doc
[ERROR] Error deleting file: aspect-ratio-9-16-2-500x500.jpg - unable to extract key from doc
[ERROR] Error deleting file: aspect-ratio-9-16-2-600x904.jpg - unable to extract key from doc
[ERROR] Error deleting file: aspect-ratio-9-16-2-1200x630.jpg - unable to extract key from doc
[ERROR] There was an error while uploading files corresponding to the collection media with filename aspect-ratio-9-16-3.jpg

Which area(s) are affected? (Select all that apply)

plugin: other

Environment Info

Binaries:
  Node: 22.12.0
  npm: 10.9.0
  Yarn: 1.22.19
  pnpm: 9.15.0
Relevant Packages:
  payload: 3.33.0
  next: 15.3.0
  @payloadcms/email-nodemailer: 3.33.0
  @payloadcms/graphql: 3.33.0
  @payloadcms/live-preview: 3.33.0
  @payloadcms/live-preview-react: 3.33.0
  @payloadcms/next/utilities: 3.33.0
  @payloadcms/payload-cloud: 3.33.0
  @payloadcms/plugin-cloud-storage: 3.38.0
  @payloadcms/plugin-form-builder: 3.33.0
  @payloadcms/plugin-nested-docs: 3.33.0
  @payloadcms/plugin-redirects: 3.33.0
  @payloadcms/plugin-search: 3.33.0
  @payloadcms/plugin-seo: 3.33.0
  @payloadcms/richtext-lexical: 3.33.0
  @payloadcms/storage-uploadthing: 3.38.0
  @payloadcms/translations: 3.33.0
  @payloadcms/ui/shared: 3.33.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions