Repository navigation
Description
Summary
infra/github-backup/bin/drain_queue.py carefully drops malformed events whose nested shapes are wrong (the #3326/#3331 owner-allowlist work: non-dict owner/account, string owners, missing repository — all DRAIN-DROP + ack, drain continues). But the event itself is never shape-checked, and its id is never checked:
queue_events(:89-108) validates only thatpage["events"]is a list — its elements are extended into the run unchecked.- The main loop (:221) calls
event_owner(ev)/event_repo(ev), which callev.get(...)(:153/:156/:172/:181) — a non-dict element (string, null, number) raisesAttributeError. - Dict events without an
idhitack.append(ev["id"])in the foreign-drop branch (:229) and the no-repo branch (:233), andids = [e["id"] for e in evs]for planned repos (:240) — all raiseKeyError: 'id'.
Either crash aborts main() before any fetch, any ack, and before state.json is written. The malformed entry stays in the Worker KV (entries carry a 7-day TTL, worker/src/index.js:5), so every 5-minute drain tick re-crashes on the same entry: the whole github-backup freshness layer wedges behind one poison event, and valid events queued behind it are never fetched or acked. This is exactly the poison-pill failure #3331 closed for nested shapes — one level up, still open.
Evidence (verified this run, laptop @ 004fd71, probe ~/git/fleet/probe-ghb-drain-poison/probe.py, real drain_queue.main() with the test harness's stub Worker/fetch pattern)
- control, valid planned event:
rc=0, fetched + acked. - control, github-backup(drain): owner allowlist crashes the whole drain run on a non-dict owner/account — malformed event becomes a poison pill instead of a DRAIN-DROP #3331 malformed-owner dict event + valid event:
rc=0, dropped + both acked. "garbage"/None/42as an event element, valid planned event behind it:AttributeError: ... has no attribute 'get'—fetched=[] acked=[].- dict event with no
id(foreign repo / no repo / planned repo):KeyError: 'id'—fetched=[] acked=[].
Why it matters
The drainer is the freshness layer of the estate mirror system (#3215): webhooks queue in the Worker, the drainer fetches mirrors. Its stated contract for malformed input is fail-closed per event — drop loudly, keep draining (#3326 docstring: "malformed events whose owner cannot be determined are dropped"). An event-level malformed shape breaks that contract catastrophically instead of per-event: one bad KV entry silently stops all mirror fetches for up to the entry's 7-day TTL, with the only signal a crashing timer unit.
Distinct from: #3331 (nested owner/account shapes inside a dict event — fixed), #6572 (queue_events pagination has no page/event bound — the read loop, not per-event shape), #3240 (non-atomic state files).
Acceptance criteria
- A non-dict event element, or a dict event with a missing/non-string
id, is DRAIN-DROP logged and skipped (it cannot be acked without an id — log it and move on); it never aborts the run. - Valid events in the same poll are still fetched/acked exactly as today, and the run summary counts dropped-malformed events.
- Regression tests in
infra/github-backup/tests/test_drain_queue.pycover: non-dict element first + valid event behind it; id-less dict in each of the foreign / no-repo / planned branches. - Existing drain suite still passes.
Activity
developing-today commentedon Nov 6, 2026
CODE-1999
dezren39 commentedon Nov 6, 2026
agent-note:v1
state: filed
agent: new-issue-creator-code-b
Found via: filed this run — verified on the laptop @004fd71699 with probe ~/git/fleet/probe-ghb-drain-poison/probe.py driving the real drain_queue.main() (stub Worker/fetch, same pattern as tests/test_drain_queue.py): non-dict event elements (string/null/number) raise AttributeError and id-less dict events raise KeyError: 'id' at drain_queue.py:229/:233/:240, in every case before any fetch/ack/state write, so the valid planned event behind the malformed one is never processed; controls (valid event; the #3331 malformed-owner dict shape) pass. Dedup: #3331 CLOSED covers nested owner/account shapes only; #6572 covers the pagination loop bound; #3240 covers state-file atomicity.
dezren39 commentedon Nov 6, 2026
🤖 Agent note · picked up
145 remaining items
dezren39 commentedon Nov 11, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 11, 2026
🤖 Agent note · parked (CI wait)
Merge pull request #8412 from developing-today/queue/14434-6575-drain…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (fixed_merged)
infra/github-backup/bin/drain_queue.py+ tests).