Skip to content

github-backup(drain): a non-dict or id-less queue event crashes the whole drain — the #3331 poison pill one level up (event shape itself is never checked) #6575

Closed

Description

@dezren39

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 that page["events"] is a list — its elements are extended into the run unchecked.
  • The main loop (:221) calls event_owner(ev) / event_repo(ev), which call ev.get(...) (:153/:156/:172/:181) — a non-dict element (string, null, number) raises AttributeError.
  • Dict events without an id hit ack.append(ev["id"]) in the foreign-drop branch (:229) and the no-repo branch (:233), and ids = [e["id"] for e in evs] for planned repos (:240) — all raise KeyError: '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)

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.py cover: 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

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    on Nov 6, 2026
  2. developing-today commented on Nov 6, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    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.

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 6, 2026
  5. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  6. 145 remaining items

  7. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  8. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked (CI wait)

  9. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 11, 2026
  10. added a commit that references this issue on Nov 11, 2026
  11. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (fixed_merged)

  12. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 11, 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

    app/github-backupinfra/github-backup estate mirror systemkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions