GeezerVison is showing github.com — projector(webhook): a delivery that fails to apply can never be retried — its error row makes every redelivery a 'duplicate', and push events are lost permanently · Issue #2456 · developing-today/code
projector(webhook): a delivery that fails to apply can never be retried — its error row makes every redelivery a 'duplicate', and push events are lost permanently #2456DescriptionSummary
In the PM projector's webhook intake, a delivery whose application fails is permanently dropped — GitHub's redelivery of the same delivery GUID is answered 200 {"status":"duplicate"} and never applied. The idempotency check asks only whether any row exists for the delivery id, but the failure paths record a row too (with outcome: "error"). So one transient failure at apply time (a locked/restarting DB, a mid-migration schema gap, a Turso hiccup) converts a retryable 500 into silent, permanent data loss. For push events the loss is absolute: pushes have no reconciliation stream (reconcile.ts covers issues, PRs, issue comments, review comments, and reviews only), so a dropped push never appears in pmp_push_events. Item/comment events are partially healed by the next reconcile poll — but only when reconcile is enabled and reaches that repo/stream, and the audit row still claims the delivery was handled.
Evidence (main 5a34fa7)
pm-stack/projector/src/store.ts:337-343 — deliveryApplied(db, deliveryId) is SELECT 1 FROM pmp_deliveries WHERE delivery_id = ? with no outcome filter: any recorded row, applied or errored, counts as "applied". (The schema comment in schema.sql states the intent as "a redelivered webhook is applied at most once" — the check as written enforces "recorded at most once".)
pm-stack/projector/src/server.ts:76-80 — the webhook handler returns 200 {status: "duplicate"} whenever deliveryApplied is true, before parsing or applying.
pm-stack/projector/src/server.ts:99 — when applyEvent throws, the handler records the delivery with outcome: "error" and returns 500. GitHub redelivers on 5xx — straight into the duplicate short-circuit above. (The invalid_json error row at :84 has the same effect for its delivery id, harmlessly, since the payload cannot change; the apply-failure row is the harmful one.)
Verified this run with a laptop Bun probe driving the real handleRequest (HMAC-signed push webhook, real store.ts, real libSQL file DB; files md5-identical to main 5a34fa7):
attempt 1 (apply fails): 500 {"error":"apply_failed"}
deliveries row after failure: [{"delivery_id":"delivery-xyz","outcome":"error"}]
attempt 2 (redelivery, same GUID): 200 {"status":"duplicate"}
push_events rows after redelivery: [{"n":0}]
The transient failure was simulated by dropping pmp_push_events for the first attempt and restoring the schema (via the real migrate) before the redelivery — the exact shape of a mid-deploy/migration hiccup. After the schema was healthy, the redelivery was still refused and the push was never recorded.
Probe: ~/git/fleet/probe-2026-10-29-laneB-projdel/probe2.ts (laptop).
Why it matters
Webhook intake is the projector's live path; reconciliation is explicitly the safety net, not the primary feed, and it does not cover pushes at all. The current code turns the one failure mode redelivery exists for — a transient 5xx — into the one outcome redelivery cannot fix. Worse, the response on redelivery is a success-shaped 200 duplicate, so nothing in GitHub's delivery log or the projector's own responses signals the loss; only the outcome: "error" audit row knows, and nothing reads it.
Acceptance criteria
- A delivery whose application failed (an
outcome: "error" row, or no row) is applied when redelivered with the same delivery GUID; only successfully applied (or genuinely ignored-after-successful-processing) deliveries short-circuit as duplicates.
- Recording a redelivery attempt does not violate the
pmp_deliveries primary key or lose the original error audit (triage pins the shape: e.g. outcome-filtered check + upsert/update on retry, or not recording failures as delivery rows while keeping an error log).
- Regression tests cover: apply-failure then same-GUID redelivery succeeds and the event's rows exist (push event recorded); successful delivery then same-GUID redelivery still returns duplicate and applies nothing twice; the invalid-JSON path's behaviour is unchanged or explicitly re-pinned by triage.
- The duplicate response remains
200 for true duplicates (GitHub must not keep retrying those).
Dedup
gh searches (open + closed) for deliveryApplied, "projector delivery", "webhook redeliver": no issue covers failed-delivery retry. #2455 (filed this run) is the projector comments monotonic guard — different mechanism in the same service. #1547 (open) is the read-API limit parameter; #1529 (open) is GitHub App key decoding.
Activitydeveloping-today commented on Oct 29, 2026 added kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/xsTrivial: expected under 30 minutes of work on Oct 29, 2026dezren39 commented on Oct 29, 2026 dezren39 commented on Oct 31, 2026 🤖 Agent note · corroboration
- Agent: new-issue-creator-code-a
- Found via: this run's filing pass — an independent reproduction of this issue (a duplicate filing, projector(webhook): a delivery whose apply failed is deduped as applied — GitHub redelivery returns 'duplicate' and the event is permanently dropped #2991, was opened in error and is being closed against this issue).
- Evidence: second laptop probe at
~/git/fleet/probe-2026-10-31-laneA-projredeliver/ (projector from main 689e47c0, real handleRequest + migrate, HMAC-signed fixtures/02-issue-opened.json): transient failure (pmp_items renamed away) → 500 {"error":"apply_failed"} + deliveries row {outcome:"error", detail:"SQLITE_ERROR: no such table: pmp_items"}; redelivery of the same GUID after healing → 200 {"status":"duplicate"}, pmp_items count 0; fresh-GUID control → applied, count 1. Confirms the defect for item events as well as the push events in the original probe.
dezren39 commented on Nov 1, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 2, 2026 dezren39 commented on Nov 2, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 2, 2026
Design architect, pass 37 (2026-11-02): this issue is adopted as Phase 1 of design #4302 (a projection writes only what the event proves — one application contract for the PM projector), together with #2982, and linked as a sub-issue of #4302. Design doc: files/designs/code-projector-application-contract.md (goal workspace).
Recorded decision for this phase: dedupe counts success and permanent failure only — deliveryApplied counts a delivery as handled iff its outcome is applied/ignored, or the row is an invalid_json error (that payload can never change, so the behaviour is unchanged there); a transient apply-error row is audit only, redelivery re-applies, and recordDelivery upserts the row retaining the prior error in detail. Triage: record the phase structure — do not re-file, re-scope or split this issue.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|