Skip to content

fix: pass id to delete access control on soft delete in updateByID#17453

Closed
vansh17June wants to merge 1 commit into
payloadcms:mainfrom
vansh17June:fix/delete-access-missing-id
Closed

fix: pass id to delete access control on soft delete in updateByID#17453
vansh17June wants to merge 1 commit into
payloadcms:mainfrom
vansh17June:fix/delete-access-missing-id

Conversation

@vansh17June

Copy link
Copy Markdown

What?

Fixes a missing id in the access.delete control callback when a document is soft-deleted (trashed) via the updateByID operation.

Why?

When a collection has trash: true, soft-deleting a document goes through the updateByID operation. The access.update callback correctly receives { id, data, req }, but the access.delete callback (called right below it for the trash check) only received { data, req }id was missing. This makes it impossible for a delete access control function to reliably identify which document is being trashed, forcing developers to rely on data.deletedAt alone, which is poor DX and was already flagged as confusing in the linked issue.

How?

One-line fix in packages/payload/src/collections/operations/updateByID.tsid was already destructured and in scope at that point in the function, so it just needed to be passed through:

- const deleteAccessResult = await executeAccess({ data, req }, collectionConfig.access.delete)
+ const deleteAccessResult = await executeAccess({ id, data, req }, collectionConfig.access.delete)

Fixes #17452

@vansh17June
vansh17June force-pushed the fix/delete-access-missing-id branch from 0025c80 to 4550b08 Compare July 22, 2026 19:10
@vansh17June vansh17June changed the title Fix/delete access missing fix(payload): pass id to delete access control on soft delete in updateByID Jul 22, 2026
@vansh17June vansh17June changed the title fix(payload): pass id to delete access control on soft delete in updateByID fix: pass id to delete access control on soft delete in updateByID Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access control missing id on soft delete operation

1 participant