payloadcms / payloadcms/payload

Media database bug (Image / PDF)

Open
#16,137 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

invalid-reproduction stale status: needs-triage
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

When you upload an image to Payload, smaller resolution versions of the image are also generated (provided you have configured this). Then you need to save.
If you edit the image after saving and replace it with a PDF, all images with the adjusted resolution are deleted, but the link in the database remains.

Image
Link to the code that reproduces this issue

i cant push the repo - i will add the media collection

Reproduction Steps
  1. Upload an Image (configure also imageSizes)
  2. Save the image
  3. Edit image and delete the upload
  4. replace the upload with an pdf

--> The images will be deleted on disk but the image size entry will be keept in database

Image
Which area(s) are affected?

Not sure

Environment Info
Binaries:
  Node: 22.16.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.80.0
  next: 16.2.1
  @payloadcms/db-mongodb: 3.80.0
  @payloadcms/email-nodemailer: 3.80.0
  @payloadcms/graphql: 3.80.0
  @payloadcms/next/utilities: 3.80.0
  @payloadcms/payload-cloud: 3.80.0
  @payloadcms/plugin-search: 3.80.0
  @payloadcms/richtext-lexical: 3.80.0
  @payloadcms/translations: 3.80.0
  @payloadcms/ui/shared: 3.80.0
  react: 19.2.4
  react-dom: 19.2.4
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 64957
  Available CPU cores: 14

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by reproducing the issue with a media collection configured with imageSizes: upload and save an image, replace it with a PDF, then inspect the database record and stored files. Done means generated image-size entries are removed from the database as well as from disk.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.