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

Aperta Adatta ai principianti
#19,448 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@volodymyrshk ci sta già lavorando.

Dal 9/11/2026.

  • #19450 di @lazerg — aperta
  • #19470 di @volodymyrshk — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
mongodb, node.js, postgresql, sqlite, typescript
Ambito
backend, databases

Direzione di ricerca

Inizia da ScheduleDrawer/index.tsx per verificare che il job memorizzi l’ID del documento come stringa, poi individua deleteScheduledPublishJobs e controlla i confronti degli ID. Aggiungi un test di regressione per eliminare un documento con un job di pubblicazione pianificata usando un ID numerico; il lavoro è completato quando il job in attesa viene rimosso, anche quando la pulizia riceve più ID.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: core Bug db: sqlite
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)
Lingua principale
TypeScript
Stelle
45.8k
Fork
4.4k
Merge medio
2g 16h
PR unite (30g)
251

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di payloadcms/payload

Tutte le issue di payloadcms/payload

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.