Skip to content

Scheduled publish jobs are not deleted when their document is deleted (string id in the job, raw id in the cleanup) #19448

Description

@volodymyrshk

Describe the Bug

deleteScheduledPublishJobs does not delete the pending scheduled publish job when its document is deleted, because it compares input.doc.value with the raw id, and the admin UI stores that value as a string.

The admin UI queues the job with value: String(id) (ScheduleDrawer/index.tsx). #10481 changed the upcoming-events query to String(id) for the same reason: a numeric id cannot be matched inside the JSON field. deleteScheduledPublishJobs still uses equals: id (and ids.map(...)), so with a numeric id it matches nothing and the job stays pending.

On SQLite (numeric ids) the script in the reproduction shows:

  • a post with a scheduled publish is deleted, and the job is still pending (1, expected 0)
  • querying input.doc.value with equals: 1 finds 0 jobs, with equals: "1" it finds 1
  • SQLite reuses the id of a deleted row, so the next post created gets that id and immediately has the stale job (1 pending, expected 0)
  • when the stale job runs, it publishes that other post: a draft that nobody scheduled ends up with status published

I have not run Postgres or MongoDB. #10481 says Postgres uses numeric ids by default, so I would expect the same mismatch there. Postgres does not reuse ids, so I would expect the stale job to fail when it runs and not to publish another document. That part is my reasoning, not something I ran.

Suggested fix: compare against String(id) (and ids.map(String)) in deleteScheduledPublishJobs. I can send a PR with a test.

Link to the code that reproduces this issue

https://github.com/volodymyrshk/payload-draft-repros

Reproduction Steps

  1. git clone https://github.com/volodymyrshk/payload-draft-repros && cd payload-draft-repros
  2. npm install
  3. npm run jobs

The output lines say what is expected. The collection is posts with versions.drafts.schedulePublish on, using @payloadcms/db-sqlite. The script uses the Local API only.

Which area(s) are affected?

area: core, db: sqlite

Environment Info

Payload: 3.93.0
@payloadcms/db-sqlite: 3.93.0
Node.js: v25.6.1
OS: macOS (Darwin)
Next.js: not used (Local API script)

Activity

  1. added
    area: core
    db: sqlite
    on Nov 9, 2026
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

    BugPayload OSSarea: coredb: sqlite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions