Repository navigation
fix: coerce schedulePublish doc.value to collection ID type before update - #17238
Merged
JessRynkar merged 1 commit intoJul 9, 2026
Conversation
…pdate input.doc.value on a schedulePublish job is always stored as a string (see payloadcms#10481, which fixed job querying against numeric Postgres IDs). The task handler passed that string straight into payload.update({ id }), which is harmless on its own but leaks into any self-referencing relationship field recomputed during the update — e.g. the breadcrumbs.doc field added by @payloadcms/plugin-nested-docs — and fails that field's relationship-ID-type validation. Adds a regression test in test/plugin-nested-docs reproducing the failure (schedulePublish on a nested-docs-enabled collection). The test explicitly stringifies the doc ID when queuing the job, matching what the real schedule-publish UI sends (client-side relationship-picker state), rather than relying on Local API calls which pass a native number and never trigger the bug. Verified: fails with "The following field is invalid: Breadcrumbs 1 > Doc" on current main, passes with this fix. Ran via: PAYLOAD_DATABASE=postgres npx vitest run --project int test/plugin-nested-docs/int.spec.ts Fixes payloadcms#17229
Contributor
Author
|
Note: closed the main-branch PR (#17236) this was backporting from — this 3.x fix is the one that actually ships in a release, so keeping just this one open. |
JessRynkar
approved these changes
Jul 9, 2026
JessRynkar
left a comment
Member
There was a problem hiding this comment.
Looks good! Appropriate fix and consistent with how ID coercion is handled elsewhere in the codebase.
JessRynkar
enabled auto-merge (squash)
July 9, 2026 11:23
Contributor
|
🚀 This is included in version v3.86.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
3.x backport of #17236.
Fixes #17229
What happened
input.doc.valueon aschedulePublishjob is always stored as a string (#10481, which fixed job querying against numeric Postgres IDs by casting the stored value to string).getSchedulePublishTask's handler passed that string straight intopayload.update({ id: input.doc.value, ... })without coercing it back to the collection's real ID type.That's harmless on its own, but it leaks into any self-referencing relationship field recomputed during the update — e.g. the
breadcrumbs.docfield added by@payloadcms/plugin-nested-docs— and fails that field's relationship-ID-type validation (isValidIDrequirestypeof value === 'number'for numeric ID collections).Full repro/root-cause writeup is in #17229.
The fix
Same as #17236, adapted to this branch's version of
job.ts(which still usespublishSpecificLocalerather than the simplifiedlocaleparam onmain): compute the target collection's real ID type and coerceinput.doc.valueto anumberwhen needed, before passing it asidtopayload.update().Test plan
Added the same regression test as #17236 in
test/plugin-nested-docs/int.spec.ts(enabledschedulePublish: trueon that project'spagesfixture collection, already wired intonestedDocsPlugin). The test explicitly doesvalue: String(draft.id)when queuing the job, matching what the real schedule-publish UI sends via client-side relationship-picker state.Verified locally against Postgres on this branch specifically:
job.tsfix reproduces the exact reported error:Error: The following field is invalid: Breadcrumbs 1 > Doctest/plugin-nested-docs/int.spec.tspass