GeezerVison is showing github.com — projector(webhook): a delivery whose apply failed is deduped as applied — GitHub redelivery returns 'duplicate' and the event is permanently dropped · Issue #2991 · developing-today/code
projector(webhook): a delivery whose apply failed is deduped as applied — GitHub redelivery returns 'duplicate' and the event is permanently dropped #2991DescriptionBug
The projector's webhook dedupe treats a delivery whose apply failed as
applied, so a GitHub redelivery of that delivery is answered 200 {"status":"duplicate"} and the event is never applied. One transient
failure (a DB hiccup, a store error mid-apply) permanently and silently
drops the event from the read model; the only recovery is the periodic
reconcile poll happening to cover that repo/stream.
Evidence (main 689e47c0)
-
pm-stack/projector/src/server.ts — the webhook handler checks
store.deliveryApplied(db, deliveryId) before applying, and on an
applyEvent throw it records the delivery and returns 500:
const already = await store.deliveryApplied(db, deliveryId);
if (already) return jsonResponse(200, { status: "duplicate" });
...
} catch (e) {
await store.recordDelivery(db, { deliveryId, event, outcome: "error", detail: ... });
return jsonResponse(500, { error: "apply_failed" });
}
The invalid_json path records outcome: "error" the same way.
-
pm-stack/projector/src/store.ts:337 — deliveryApplied ignores the
recorded outcome entirely:
SELECT 1 AS x FROM pmp_deliveries WHERE delivery_id = ?
Any row — applied, ignored, or error — makes every later
delivery of that GUID a "duplicate".
-
pm-stack/projector/schema.sql:98 — pmp_deliveries.delivery_id is
the PRIMARY KEY ("a redelivered webhook is applied at most once"), so
a fix that retries on redelivery must also make the second
recordDelivery an upsert/replace rather than a bare INSERT, or the
retry succeeds and its bookkeeping insert throws.
Reproduction (verified this run)
Probe on the laptop (~/git/fleet/probe-2026-10-31-laneA-projredeliver/,
real handleRequest + migrate + HMAC-signed fixture
fixtures/02-issue-opened.json, projector sources copied from main
689e47c0):
pmp_items briefly renamed away → signed delivery
probe-delivery-1 returns 500 {"error":"apply_failed"} and
pmp_deliveries gains {delivery_id: "probe-delivery-1", outcome: "error", detail: "SQLITE_ERROR: no such table: pmp_items"}.
- Table restored, the same delivery redelivered →
200 {"status":"duplicate"} and pmp_items count stays 0 —
the issue-opened event is lost.
- Control: the same body under a fresh delivery id →
200 {"status":"applied","refs":["developing-today/code#754"]},
item count 1.
Why it matters
The projector is the PM stack's read model for issues/PRs/comments.
Webhook intake is supposed to be at-least-once-safe: GitHub redelivers
(automatically on 5xx in some paths, and manually from the App UI after
an incident) precisely so transient failures heal. Here the failure is
recorded in the very table that gates redelivery, converting a
transient error into permanent, silent data loss — the deliveries audit
even shows the delivery as present, so nothing looks missing until
someone notices a stale item. Distinct from #2982 (a missing
X-GitHub-Delivery header collapsing distinct deliveries onto the
empty-string key): this is about deliveries that have an id and
failed.
Acceptance criteria
- A delivery recorded with
outcome = 'error' does not count
as applied: redelivering it re-runs applyEvent and, on success,
returns applied/ignored and the writes land.
- Recording the retried delivery's outcome does not violate the
pmp_deliveries primary key (upsert/replace semantics), and the
audit row reflects the final outcome.
- A delivery recorded
applied or ignored still short-circuits
as duplicate (existing e2e idempotency test keeps passing).
- Regression test beside the projector tests: fail an apply
(transient store error), redeliver the same delivery id, assert
it applies; and a redelivery after an error does not throw on
the deliveries insert.
- Triage pins the
invalid_json case: a malformed-body delivery
can never succeed on redelivery — either it stays deduped
deliberately (documented) or it is excluded from the deliveries
table; either way the choice is explicit, not accidental.
Activitydezren39 commented on Oct 31, 2026 🤖 Agent note · filed
- Agent: new-issue-creator-code-a
- Session / ID: cron job new-issue-creator-code-a, run 2026-10-31 03:05 CDT
- Found via: filed this run
- Task: Stop the projector webhook dedupe from treating a failed apply as applied: a delivery recorded outcome=error must be retried on GitHub redelivery (and its audit insert must survive the pmp_deliveries primary key), while applied/ignored deliveries still dedupe.
- Expectation: effort/s — done when the acceptance criteria on this issue pass, including the fail-then-redeliver regression test.
- Links: evidence in the issue body; laptop probe at ~/git/fleet/probe-2026-10-31-laneA-projredeliver/ (real handleRequest + store, main 689e47c: first attempt 500 apply_failed + outcome=error row, redelivery 200 "duplicate" with 0 items, fresh-id control applied).
dezren39 commented on Oct 31, 2026 🤖 Agent note · duplicate — closing against #2456
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|