Repository navigation
Description
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-indexeslock_data["nodes"]["root"]["inputs"](:185) andlock_data["nodes"][node_name](:191) —KeyErrorwhereget_input_node/discover_inputsguard the same lookups.get_input_info(:192-193),get_input_ref(:228),get_locked_rev(:236) anddiscover_inputs(:263) all use.get("original", {})/.get("locked", {})— the{}default does not help when the key is present with an explicit JSONnull, so a nulloriginal/lockedraisesAttributeError: 'NoneType' object has no attribute 'get'.discover_inputs(:266) andget_input_info(:195) call.lower()onoriginal.typewithout a string check — a non-stringtyperaisesAttributeError.get_input_info(:196-197) doeslen(full_rev)/ slicing onlocked.revunchecked — and this is the dangerous one:discover_inputsnever readslocked.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_inputsandget_input_refwithAttributeError: 'str' object has no attribute 'get'; a root-named node missing fromnodesis skipped bydiscover_inputsbut raisesKeyErroringet_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
- Mid-run death after partial updates leaves flake.lock half-updated with no summary of what changed — the operator cannot tell which inputs moved.
- The script's own contracts are inconsistent: remote Hydra payloads get strict shape validation and a clean fail-closed error (fix(scripts): gate nixpkgs-unstable input updates on the Hydra channel (cached) revision #4553), while the local file it exists to rewrite gets raw tracebacks.
- Both copies carry the defect; the pkgs/id copy is what the pkgs/id just recipes run (id(scripts): pkgs/id copy of update-nixpkgs-inputs never got the #598 exit-code fix — failed updates exit 0 via the pkgs/id just recipes, and its wrapper re-runs the whole update on any genuine failure #2783).
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-objectoriginalorlocked, a non-stringtype/ref/rev, and a missing node/root consistently: either the input is skipped (mirroring the existing missing-node handling indiscover_inputs) or the run aborts with a clear, named error before any input is updated — never a rawAttributeError/TypeError/KeyErrortraceback. - 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.pycover 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
developing-today commentedon Nov 7, 2026
CODE-2115
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
56 remaining items
test(scripts): property coverage for the lock-reader totality invaria…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · resumed by lane code-b
repo-health-code-pilot· kindsmall_fix· issue 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 · PR fix(scripts): make update-nixpkgs-inputs flake.lock readers total over wrong shapes (#6847) #8688python3 -m unittest scripts.tests.test_update_nixpkgs_inputs— 23 tests OK; both script copies byte-identical (cmpclean). CI checks on the PR fail repo-wide at ~58s (runner stall noted fleet-wide); merging on local verification + Codex per charter.fix(scripts): make update-nixpkgs-inputs flake.lock readers total ove…
dezren39 commentedon Nov 11, 2026
🤖 Agent note · done (lane code-b)