Skip to content

update-nixpkgs-inputs: wrong-shape flake.lock nodes crash the updater with raw tracebacks — get_input_info direct-indexes what the other readers guard, and a non-string locked.rev crashes mid-run after earlier inputs are already updated #6847

Closed

Description

@dezren39

Summary

update-nixpkgs-inputs.py (two byte-identical copies: scripts/update-nixpkgs-inputs.py and pkgs/id/scripts/update-nixpkgs-inputs.py; the test suite enforces byte-identity) reads flake.lock through five helpers that disagree about shape safety. The Hydra gate added in #4553 validates its remote payloads strictly and fails closed with HydraGateError, and some lock readers use .get chains — but the local lock readers were never given the same treatment:

  • get_input_info (line 180) direct-indexes lock_data["nodes"]["root"]["inputs"] (:185) and lock_data["nodes"][node_name] (:191) — KeyError where get_input_node/discover_inputs guard the same lookups.
  • get_input_info (:192-193), get_input_ref (:228), get_locked_rev (:236) and discover_inputs (:263) all use .get("original", {}) / .get("locked", {}) — the {} default does not help when the key is present with an explicit JSON null, so a null original/locked raises AttributeError: 'NoneType' object has no attribute 'get'.
  • discover_inputs (:266) and get_input_info (:195) call .lower() on original.type without a string check — a non-string type raises AttributeError.
  • get_input_info (:196-197) does len(full_rev) / slicing on locked.rev unchecked — and this is the dangerous one: discover_inputs never reads locked.rev, so a non-string rev passes the planning pass and only crashes inside the per-input execution loop (main, :487), i.e. potentially after earlier inputs in the same run have already been updated or pinned and flake.lock rewritten for them. The run dies with a raw traceback, no summary, and no per-input failure record.
  • A node that is a string instead of an object crashes discover_inputs and get_input_ref with AttributeError: 'str' object has no attribute 'get'; a root-named node missing from nodes is skipped by discover_inputs but raises KeyError in get_input_info.

flake.lock is normally nix-generated, but it is also hand-edited (this repo's history includes hand-pinned locks and gated pins written by this very script, pin_input), merged, and occasionally truncated/conflicted — exactly the states where the updater is re-run to repair things. A repair tool that tracebacks on the malformed states it may be asked to fix, and that can die mid-run after partially rewriting the lock, is worse than one that refuses cleanly up front.

Evidence (verified this run, laptop @ 65beb42)

Probe ~/git/fleet/probe-nixpkgs-inputs-shape/probe.py imports the real scripts/update-nixpkgs-inputs.py and feeds it a well-formed lock plus one mutation at a time. Controls all pass: discover → ['nixpkgs'], info → ('aaaaaaaaaaaa', 'github:NixOS/nixpkgs/nixos-unstable', 'nixos-unstable'), ref and locked_rev correct.

Malformed shapes (11 cases):

mutation result
node is a string discover + get_input_ref: AttributeError: 'str' object has no attribute 'get'
original: null discover + get_input_ref + get_input_info: AttributeError: 'NoneType' object has no attribute 'get'
original.type: 7 discover + get_input_info: AttributeError: 'int' object has no attribute 'lower'
locked.rev: 123 discover: OK (planning passes); get_input_info: TypeError: object of type 'int' has no len(); get_locked_rev returns 123 unchecked
locked: null get_input_info + get_locked_rev: AttributeError
node missing from nodes discover: [] (guarded); get_input_info: KeyError: 'nixpkgs-node'
no root node discover: [] (guarded); get_input_info: KeyError: 'root'

Why it matters

Acceptance criteria

  • All flake.lock readers (get_input_info, get_input_node, get_input_ref, get_locked_rev, discover_inputs) treat a non-object node, a null/non-object original or locked, a non-string type/ref/rev, and a missing node/root consistently: either the input is skipped (mirroring the existing missing-node handling in discover_inputs) or the run aborts with a clear, named error before any input is updated — never a raw AttributeError/TypeError/KeyError traceback.
  • Validation happens in the planning pass (against the pristine lock), so a malformed lock can never crash the execution loop after earlier inputs have been written.
  • Regression tests in scripts/tests/test_update_nixpkgs_inputs.py cover the shapes above against both byte-identical copies (root + pkgs/id), following the suite's existing both-copies pattern.
  • Well-formed locks behave exactly as today (existing tests green, including the Hydra gate and byte-identity tests).

🤖 Filed by new-issue-creator-code-b (Lane B), run 2026-11-07 01:20 CST. Probe: ~/git/fleet/probe-nixpkgs-inputs-shape/ on the laptop.

Activity

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

    @developing-today
    Contributor
  3. added
    area/nixNix expressions, flakes, and packaging
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 7, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  5. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  6. added
    work/assignedQueue worker lifecycle state
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    and removed on Nov 8, 2026
  7. 56 remaining items

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

    @dezren39
    MemberAuthor

    🤖 Agent note · resumed by lane code-b

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/idPackage/app: id (pkgs/ or apps/ in this repo)area/nixNix expressions, flakes, and packagingkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus: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