Describe the Bug
Hi, I noticed that setting trash: true does indeed remove items from the list when running something like GET /api/article with trash: true not set.
However, if article has a relationship to another collection such as writers (e.g. hasMany relationship field: writers, so response is: {writers: {docs: [{id: 1, name: 'some name'}, {id: 2, name: 'some other name'}]}}), the id of a trashed entry persists, and becomes: {writers: {docs: [1, {id: 2, name: 'some other name'}]}}
My initial expectation was that 1 wouldn't appear in the response at all and I would get: {writers: {docs: [{id: 2, name: 'some other name'}]}}
Link to the code that reproduces this issue
https://github.com/amroweh2/payload-trash-bug
Reproduction Steps
- Create
Article and Writer collections
- Set the
Article to have a hasMany relation to the Writer collection
- Set the
Writer collection to have trash: true
This has already bee setup in the repo attached, so by running pnpm run dev and hitting http://localhost:3000/api/article/1, notice that the writers associated to that article have the following structure:
"writers": [
1,
{
"id": 2,
"name": "some other name",
"updatedAt": "2026-03-20T23:43:06.224Z",
"createdAt": "2026-03-20T23:43:06.224Z",
"deletedAt": null
}
],
notice that the id = 1 is still returned
Which area(s) are affected?
area: core
Environment Info
Binaries:
Node: 22.12.0
npm: 10.9.0
Yarn: N/A
pnpm: 10.32.1
Relevant Packages:
payload: 3.80.0
next: 16.2.0
@payloadcms/db-sqlite: 3.80.0
@payloadcms/drizzle: 3.80.0
@payloadcms/graphql: 3.80.0
@payloadcms/next/utilities: 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: darwin
Arch: arm64
Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:51:28 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6041
Available memory (MB): 24576
Available CPU cores: 12
Describe the Bug
Hi, I noticed that setting
trash: truedoes indeed remove items from the list when running something like GET/api/articlewithtrash: truenot set.However, if
articlehas a relationship to another collection such aswriters(e.g. hasMany relationship field:writers, so response is:{writers: {docs: [{id: 1, name: 'some name'}, {id: 2, name: 'some other name'}]}}), the id of a trashed entry persists, and becomes:{writers: {docs: [1, {id: 2, name: 'some other name'}]}}My initial expectation was that 1 wouldn't appear in the response at all and I would get:
{writers: {docs: [{id: 2, name: 'some other name'}]}}Link to the code that reproduces this issue
https://github.com/amroweh2/payload-trash-bug
Reproduction Steps
ArticleandWritercollectionsArticleto have ahasManyrelation to theWritercollectionWritercollection to havetrash: trueThis has already bee setup in the repo attached, so by running
pnpm run devand hittinghttp://localhost:3000/api/article/1, notice that the writers associated to that article have the following structure:notice that the
id = 1is still returnedWhich area(s) are affected?
area: core
Environment Info