payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
27.66k stars 1.72k forks source link

Filtered Bulk Delete Ends Up Deleting Everything #9374

Closed nathanclevenger closed 1 day ago

nathanclevenger commented 1 day ago

Describe the Bug

If a list view is searched, and then the Select all x Resources is clicked, and then if delete is selected, all documents from the collection are deleted not just the filtered/selected items.

This is an extremely serious issue - we just had to roll back a database to backup and lost data because of this bug.

Link to the code that reproduces this issue

https://github.com/nathanclevenger/payload-repro

Reproduction Steps

Go to a collection list view: Image

Enter a search term: Image

Hit the top checkbox to select all: Image

Hit the link to "Select All x Resources: Image

Hit Delete, and Confirm: (note, it shows the filtered count here) Image

Then all resources in the collection will be deleted: Image

I confirmed this exists in both Mongo and Postgres

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

Not sure

Environment Info

Payload: 3.0.1
Nextjs: 15.0.0
Node: 20.13.1
jacobsfletch commented 1 day ago

@nathanclevenger I'm unable to reproduce this within either our test suite or the reproduction repo you've provided. Here's a quick screen recording from my end using the steps you've outlined:

https://github.com/user-attachments/assets/ea36cd54-e653-4110-8dfc-61e075520d8b

tyteen4a03 commented 1 day ago

@nathanclevenger I'm unable to reproduce this within either our test suite or the reproduction repo you've provided. Here's a quick screen recording from my end using the steps you've outlined: issue-9374-no-repro.mp4

Similar to #9264, maybe the issue only appears if you follow the instructions exactly? Your setup has 3 and you select 1, while their setup has 4 and selected 3.

jacobsfletch commented 1 day ago

Ahh @nathanclevenger missed a step, just coming back in here to confirm but I see @tyteen4a03 is too quick for me. Looking into it.

jacobsfletch commented 1 day ago

Your setup has 3 and you select 1, while their setup has 4 and selected 3.

For the record it's the "Hit the link to "Select All x Resources" step that reproduces this issue. Not the number of documents.

nathanclevenger commented 1 day ago

Your setup has 3 and you select 1, while their setup has 4 and selected 3.

For the record it's the "Hit the link to "Select All x Resources" step that reproduces this issue. Not the number of documents.

Yes, it's the Select All x Resources that causes this issue ... I just confirmed it also affects Updates as well as Deletes

github-actions[bot] commented 1 day ago

🚀 This is included in version v3.0.2

github-actions[bot] commented 9 hours ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.