Skip to content

schedulePublish task fails with "invalid relationships" on collections using @payloadcms/plugin-nested-docs breadcrumbs (Postgres, numeric IDs) #17229

Closed

Description

@aevarOrigo

Describe the Bug

After #10481 fixed job querying by always storing input.doc.value as a string, getSchedulePublishTask's handler still passes that string straight into payload.update({ id: input.doc.value, ... }) without coercing it back to the collection's real ID type. For plain collections this is harmless. But for a collection using @payloadcms/plugin-nested-docs, the plugin's beforeChange hook recomputes the breadcrumbs array on every update, and its self-referencing entry sets doc: currentDocument.id — which inherits that same string, since currentDocument.id = originalDoc?.id ?? data?.id traces back to the string id used in the update call.

That string then fails Payload's own relationship-field validator (fields/validations.js), which does a strict typeof value === 'number' check via isValidID() for numeric (Postgres default) ID types. The scheduled publish job errors out and never completes.

Confirmed via instrumentation (temporary console.logs, since removed):

[DEBUG schedulePublish] input.doc.value = "1" typeof = string
[DEBUG formatBreadcrumb] lastDoc.id = "1" typeof = string
[DEBUG relationship validate] requestedID = "1" typeof = string idType = number invalid = true

(other relationship fields on the same document validate fine — numeric IDs throughout — this one field alone carries the leaked string)

Link to the code that reproduces this issue

N/A — reproduction steps below use a standard Postgres + nested-docs-plugin setup.

Reproduction Steps

  1. Postgres adapter, default numeric IDs.
  2. A collection with versions: { drafts: { schedulePublish: true } }, registered in nestedDocsPlugin({ collections: [...] }).
  3. Schedule a publish on any document in that collection (a root document with no parent is enough).
  4. Trigger the job runner (GET /api/payload-jobs/run or autoRun).
  5. Job fails with a validation error naming the breadcrumbs field's doc subfield as invalid (e.g. "This field is invalid: Breadcrumbs 1 > Doc").

Expected behavior

Scheduled publish succeeds regardless of whether the target collection has a nested-docs-style self-referencing relationship field.

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

db-postgres, area: core, plugin: nested-docs

Environment Info

Relevant Packages:
  payload: ^3.85.1
  @payloadcms/db-postgres: ^3.85.1
  @payloadcms/plugin-nested-docs: ^3.85.1
  next: 16.2.9
  react: 19.2.7
Binaries:
  Node: v22.14.0

Related

#10283, fixed by #10481 (the string-casting change that introduced this regression)

Activity

  1. added
    area: core
    plugin: nested-docs
    on Jul 7, 2026
  2. added a commit that references this issue on Jul 9, 2026
    d245ab8
  3. added a commit that references this issue on Jul 9, 2026
    7de11b2
  4. github-actions commented on Jul 10, 2026

    @github-actions
    Contributor

    🚀 This is included in version v3.86.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    (Select all that apply) db-postgresarea: coreplugin: nested-docs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions