Skip to content

github-backup(clone_all+manifest): a wrong-shape reference/branch field passes validate_plan and crashes both consumers — the #6637 gate checks only repo #6834

Closed

Description

@dezren39

github-backup(clone_all+manifest): a wrong-shape reference/branch field passes validate_plan and crashes both consumers — the #6637 gate checks only repo

Evidence

Verified on the laptop at origin/main e380645a3b7c94e47dabda544564d7fd89c75416. ghb_common.validate_plan (infra/github-backup/bin/ghb_common.py:149-165, the #6637 gate every plan consumer now shares via load_plan) validates exactly one field: an entry is kept iff it is a dict with a string repo. The other plan fields consumers actually compute with — reference and branch — pass through at any JSON shape.

Consumers that break on those fields:

  • infra/github-backup/bin/clone_all.py:202-214 — the main-thread scheduler does state.get(ref) (and later state.get(ref) == "ok") on p.get("reference"). A list or dict reference is unhashable: TypeError: cannot use 'list' as a dict key. The crash is in the scheduling loop, not in a worker thread, so the whole clone run dies: remaining pending repos are never submitted, in-flight results are never recorded to clone-status.jsonl, and no DONE summary prints.
  • infra/github-backup/bin/clone_all.py:147-149 — mirror_path(root, ref) would also fail on a non-string reference (ref + ".git"), but the scheduler crash fires first.
  • infra/github-backup/bin/manifest.py:58 — families.setdefault(item["reference"], []) raises the same unhashable TypeError for a list/dict reference; MANIFEST.json and FAMILIES.md are never rewritten.
  • infra/github-backup/bin/manifest.py:81 — sorted(families): a numeric reference alongside string references raises TypeError: '<' not supported between instances of 'str' and 'int'; a lone numeric reference silently writes ## anchor: 123 into FAMILIES.md.
  • infra/github-backup/bin/manifest.py:15-16,50 — head_sha(path, item.get("branch")) builds "refs/heads/" + branch; a non-string branch (int, list) on a repo whose mirror is present raises TypeError: can only concatenate str (not "int") to str.

Probe (laptop, ~/git/fleet/probe-ghb-reference-shape/probe.py + probe2.py, real ghb_common / clone_all / manifest modules from origin/main, temp roots, controls included):

  • validate_plan([{repo, reference: [..]}, {repo, reference: {..}}, {repo, reference: "o/anchor"}]) → kept=3, problems=[] — the gate is blind to the field shape.
  • clone_all.main with reference: ["o/anchor"] → TypeError: cannot use 'list' as a dict key (unhashable type: 'list'); with reference: {"x": 1} → same for dict. String and null reference controls complete the run normally.
  • manifest.build with list/dict reference → same unhashable TypeError, no manifest written; string control → OK totals={'mirrored': 0, 'missing': 1, 'disk_kb': 0}.
  • manifest.build with references 123 + "o/anchor" in one plan → TypeError: '<' not supported between instances of 'str' and 'int' at the sorted(families) pass.
  • manifest.build with a present bare mirror and branch: 123 / branch: ["main"] → TypeError: can only concatenate str (not "int") to str; branch: "main" control → OK, mirrored=1.

Why it matters

plan.json is the shared input to the clone driver and the manifest regenerator, and it is exactly the file class the estate keeps poisoning itself with (hand edits, older/newer writers, torn writes per #3240). #6637 hardened the entry level and #6821 the last_fetch field of state entries, but the plan's own field level was never validated: one wrong-shape reference wedges the resumable clone driver for every repo (not just the poisoned one) and separately wedges MANIFEST regeneration — the disaster-recovery source of record — on every subsequent run until someone hand-edits the JSON. A numeric reference is worse in one way: it does not crash clone_all at all (it is silently ignored there), so the corruption is invisible until manifest's mixed-type sort or a bogus FAMILIES.md anchor surfaces it.

Distinct from: #6637 (plan entry-level shape + state fail_days/drain_*), #6821 (state last_fetch field, fetch consumer), #6653 (manifest entry-level, fixed via load_plan), #6831 (reconcile reading the previous plan bypassing validate_plan), #6822/#6814 (other repos' seed/artifact field shapes). None validates the plan reference/branch fields.

Acceptance criteria

  • validate_plan validates the consumed plan fields: reference and branch (and parent, copied into the manifest) must be strings or null/absent; a wrong-shape field produces a named problem via report_problems and is neutralized (field dropped to None, or the entry skipped with the entry named — either contract is acceptable if explicit and tested), never passed through to a consumer.
  • With such a plan file, clone_all.main completes its scheduling loop (poisoned entries/repos are reported, other repos still clone or fail on their own merits, DONE prints) and manifest.build still writes MANIFEST.json + FAMILIES.md.
  • A numeric reference can no longer produce a bogus ## anchor: 123 family or a mixed-type sort crash.
  • Regression tests in infra/github-backup/tests/ (extending test_plan_state_shape.py and the manifest/clone tests) cover list/dict/int reference, int/list branch with a present mirror, and the string/null controls; the existing github-backup suite stays green.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/github-backupinfra/github-backup estate mirror system
    on Nov 7, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-07 00:20 CST
    • Found via: filed this run
    • Task: Field-level residual of github-backup(fetch): a valid-JSON but wrong-shape plan/state entry crashes the whole daily fetch — one poison entry in plan.json or state.json wedges every repo, every day #6637: validate_plan checks only the repo field; a list/dict reference crashes clone_all's main-thread scheduler (clone_all.py:205, unhashable dict key) and manifest's families grouping (manifest.py:58), a numeric reference crashes manifest's sorted(families) when mixed with strings, and a non-string branch crashes head_sha (manifest.py:16) for present mirrors. Verified with the real modules from origin/main e380645 on the laptop (probe ~/git/fleet/probe-ghb-reference-shape).
    • Expectation: effort/s small-fix — validate reference/branch/parent field shapes in validate_plan (string or null; named problem + neutralize), regression tests; queued for the repo worker.
    • Links: packet creator-b-2026-11-07-0020/packet-6834-small-fix.json (goal hidden_files)
  5. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

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

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

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

    @dezren39
    MemberAuthor

    Picked up the resumed queue task 11053 for #6834 to recheck PR #7004 after its CI wait. Fresh state remains OPEN with no hard-stop labels; the required checks are still queued.\n\n

  10. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked for CI\n- Agent: repo-worker-code, OpenChamber scheduled lane 262eb403-3347-4a7c-ba6b-e7bc263ca853\n- Task: 11053 for #6834; PR #7004 remains OPEN.\n- Checks: basic: proxy port fallbacks and scripts-test on Python 3.12/3.14 are still queued after more than 27 minutes; CodeRabbit skipped, no reviews found.\n- Resume: recheck after 20 minutes; this lane holds no claim while CI runs.\n

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

    @developing-today
    Contributor

    🤖 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 jobtask/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