Repository navigation
fix(ui): scheduled publish not showing related events in postgres - #10481
Merged
DanRibbens merged 1 commit intoJan 13, 2025
Merged
DanRibbens merged 1 commit into
DanRibbens merged 1 commit into
Conversation
DanRibbens
approved these changes
Jan 10, 2025
Contributor
|
@paulpopus please add a description before this is merged. |
DanRibbens
deleted the
fix/scheduled-publish-not-showing-related-events-in-postgres
branch
January 13, 2025 17:35
Contributor
|
🚀 This is included in version v3.17.0 |
kendelljoseph
pushed a commit
that referenced
this pull request
Feb 21, 2025
…0481) Since postgres uses number IDs by default, when we were storing the relationship field value with postgres we weren't able to query it This fixes that problem by casting the ID to always a string making it safe for querying inside the JSON field
This was referenced Jul 7, 2026
JessRynkar
pushed a commit
that referenced
this pull request
Jul 9, 2026
…date (#17236) Fixes #17229 ### What happened `input.doc.value` on a `schedulePublish` job 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 into `payload.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.doc` field added by `@payloadcms/plugin-nested-docs` — and fails that field's relationship-ID-type validation (`isValidID` requires `typeof value === 'number'` for numeric ID collections). Full repro/root-cause writeup is in #17229. ### The fix Compute the target collection's real ID type and coerce `input.doc.value` to a `number` when needed, before passing it as `id` to `payload.update()`. ### Test plan Added a regression test in `test/plugin-nested-docs/int.spec.ts` (enabled `schedulePublish: true` on that project's `pages` fixture collection, which is already wired into `nestedDocsPlugin`). The test explicitly does `value: String(draft.id)` when queuing the job — matching what the real schedule-publish UI sends via client-side relationship-picker state — since calling `payload.jobs.queue()`/`schedulePublishHandler` directly from Node passes a native `number` and doesn't trigger the bug on its own. Verified locally against Postgres: - Reverting just the `job.ts` fix reproduces the exact reported error: `Error: The following field is invalid: Breadcrumbs 1 > Doc` - With the fix, all 12 tests in `test/plugin-nested-docs/int.spec.ts` pass ``` PAYLOAD_DATABASE=postgres npx vitest run --project int test/plugin-nested-docs/int.spec.ts ```
JessRynkar
pushed a commit
that referenced
this pull request
Jul 9, 2026
…date (#17238) 3.x backport of #17236. Fixes #17229 ### What happened `input.doc.value` on a `schedulePublish` job 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 into `payload.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.doc` field added by `@payloadcms/plugin-nested-docs` — and fails that field's relationship-ID-type validation (`isValidID` requires `typeof 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 uses `publishSpecificLocale` rather than the simplified `locale` param on `main`): compute the target collection's real ID type and coerce `input.doc.value` to a `number` when needed, before passing it as `id` to `payload.update()`. ### Test plan Added the same regression test as #17236 in `test/plugin-nested-docs/int.spec.ts` (enabled `schedulePublish: true` on that project's `pages` fixture collection, already wired into `nestedDocsPlugin`). The test explicitly does `value: 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: - Reverting just the `job.ts` fix reproduces the exact reported error: `Error: The following field is invalid: Breadcrumbs 1 > Doc` - With the fix, all 12 tests in `test/plugin-nested-docs/int.spec.ts` pass ``` PAYLOAD_DATABASE=postgres npx vitest run --project int test/plugin-nested-docs/int.spec.ts ```
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.
Since postgres uses number IDs by default, when we were storing the relationship field value with postgres we weren't able to query it
This fixes that problem by casting the ID to always a string making it safe for querying inside the JSON field