Skip to content

github-backup(manifest): a valid-JSON but wrong-shape plan/state entry crashes the whole manifest regeneration — MANIFEST.json (the DR source) is never rewritten #6653

Closed

Description

@dezren39

github-backup(manifest): a valid-JSON but wrong-shape plan/state entry crashes the whole manifest regeneration — MANIFEST.json (the DR source) is never rewritten

Evidence

infra/github-backup/bin/manifest.py, build() (verified on laptop at origin/main fff580fb1e):

  • :36 / :38 — plan and state are loaded with bare json.load and never shape-checked.
  • :41-42 — for item in plan: repo = item["repo"] subscripts every plan entry unguarded.
  • :49 — "last_fetch": (state.get(repo) or {}).get("last_fetch") assumes every state value is a dict (or falsy).

Verified this run with a probe on the laptop (~/git/fleet/probe-manifest-shape/probe_manifest.py, real manifest.build() against temp roots, only load_config stubbed):

  • Controls pass: valid plan+state → OK totals={'mirrored': 0, 'missing': 1, 'disk_kb': 0}; empty plan/state → OK.
  • Malformed shapes all raise, and no MANIFEST.json/FAMILIES.md is written:
    • plan entry 123 → TypeError: 'int' object is not subscriptable
    • plan entry "o/r" → TypeError: string indices must be integers
    • plan entry [] → TypeError: list indices must be integers or slices
    • plan entry {"size_kb": 1} (no repo) → KeyError: 'repo'
    • plan top-level {"repo": "o/r"} (dict, not list) → TypeError: string indices must be integers
    • state entry {"o/r": 123} → AttributeError: 'int' object has no attribute 'get'
    • state entry {"o/r": "t"} → AttributeError: 'str' object has no attribute 'get'
    • state top-level [] → AttributeError: 'list' object has no attribute 'get'

Why it matters

MANIFEST.json is the disaster-recovery source of record (module docstring: it records what DOES exist, where, and its state; together with config.json it rebuilds the whole backup tree). One poison entry in plan.json or state.json — written by another tool, a hand edit, or a partial migration — wedges every regeneration: the manifest silently goes stale while mirrors keep changing, and the failure surfaces only at DR time, when the stale manifest is trusted. The poison entry also re-crashes every subsequent run until someone hand-edits the JSON. Sibling consumers were hardened/filed separately (#6637 fetch, #6606 reconcile); manifest is the remaining unguarded consumer of the same two files. Distinct from #3240, which covers torn/invalid JSON and non-atomic writes — this is valid JSON with the wrong shape.

Acceptance criteria

  • build() validates plan/state shape: a non-list plan, a non-dict state, a plan entry that is not a dict with a string repo, or a non-dict state value produces a clear, named error (or a per-entry skipped/error record) instead of a raw TypeError/KeyError/AttributeError traceback.
  • Valid entries in the same file still regenerate MANIFEST.json + FAMILIES.md (or the run fails atomically with the offending entry named — either contract is acceptable if it is explicit and tested).
  • Regression tests in infra/github-backup/tests/ cover the malformed shapes above against the real build().

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 7, 2026
  2. developing-today commented on Nov 7, 2026

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

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Picked up by repo-worker-code-y (Lane Y queue worker shift, FALLBACK MODE — queue backend down: fleet queue health returns HTTP 503 PGRST002; fallback protocol in doc/fleet/queue-fallback-mode.md followed manually via the gh CLI, the fallback subcommand not yet being in the deployed fleet 0.1.0 binary).

    🤖 Agent note · picked up

  5. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 7, 2026
  6. 11 remaining items

  7. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Picked up by repo-worker-code-l — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while repo-worker-code-l posts progress markers; after 30 minutes of silence any other worker may pick this up.)

    🤖 Agent note · picked up

  8. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 7, 2026
  9. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Progress from repo-worker-code-l: implementation_complete: 4 manifest-specific regression tests added to test_plan_state_shape.py (24/24 pass at head); all 5 ManifestShapeTests error on pre-#6696 main a2e6549 with exactly the documented TypeError/AttributeError shapes; next: full suite, commit, PR

  10. added a commit that references this issue on Nov 7, 2026
  11. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    Released by repo-worker-code-l (outcome: done). Issue #6653 COMPLETED and merged: PR #6706 #6706 (branch queue/fallback-6653-manifest-shape-tests, merge commit 8e20f10). The production validation for manifest build() had already landed via PR #6696 (issue #6637, shared ghb_common validators, per the coordination note); this claim landed the remaining acceptance scope — manifest-specific regression tests against the real build() for every probe shape (plan entry 123 / string / list / missing repo, plan top-level dict, state entry int / string, state top-level list). Verified: 24/24 in test_plan_state_shape.py and full github-backup suite green at head; all 5 ManifestShapeTests error on pre-#6696 main a2e6549 with exactly the documented exceptions. Codex review: no findings. Issue auto-closed by the PR.

    🤖 Agent note · done

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/triagedTriaged and routed (see agent note)status:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions