GeezerVison is showing github.com — deploy(deploy.py): duplicate JSON keys in the registry are silently discarded at load — an invalid first definition is never validated · Issue #6384 · developing-today/code
deploy(deploy.py): duplicate JSON keys in the registry are silently discarded at load — an invalid first definition is never validated #6384Descriptiondeploy(deploy.py): duplicate JSON keys in the registry are silently discarded at load — an invalid first definition is never validated
pkgs/deploy/deploy.py's module docstring states the contract: validation "is the oracle for 'well-formed definition'... Any violation is reported by field and makes list exit non-zero — a registry that cannot be validated must never be enumerated as if it were trustworthy." That oracle never gets the chance to run on a duplicated key: load_registry (deploy.py:149-151) is a bare json.load(fh), and Python's json silently keeps only the last value for a repeated key, at every nesting level. The discarded text is never parsed into the registry, never validated, and never reported.
Verified on the laptop against the real deploy.py (tree @1dae17e457, file unchanged on origin/main @8f2cf5dd62; probe: ~/git/fleet/probe-deploy-dupkeys/probe.py + probe2.py on the laptop):
1. Duplicate service name: an invalid first definition vanishes
Registry text defining svc twice — first with "class": "bogus-class", then with a valid definition:
== dup service key, invalid-first/valid-second: exit=0
stdout: NAME CLASS TARGETS | svc systemd laptop
deploy list exits 0 and enumerates the service as trustworthy; the invalid definition was discarded before validate() (deploy.py:55) could see it. Control: the same invalid definition on its own is correctly rejected (exit 1, "class must be one of ..."). Reversed order (valid first, invalid second) exits 1 only because the invalid copy happens to be the survivor — the behaviour depends on key order, not on validity.
2. Duplicate field inside a definition: an invalid first value vanishes
A definition carrying "ports": "notalist" first and a valid "ports": [] second:
== dup field ports string-then-valid-list: exit=0
Exit 0 — the malformed value the field check at deploy.py:113-124 exists to catch was dropped at load. (Valid-first/invalid-second exits 1, again only by order luck.)
3. Duplicate key inside environment
"environment": {"A": "1", "A": "2"} → exit 0; one of the two values is silently lost. For environment maps that later slices render into service units, a silently dropped value is a configuration that differs from what the registry author wrote, with no signal.
Why this is its own finding (not #6383 / #6376)
Acceptance criteria
- Loading a registry whose text contains a duplicate key — at the top (service) level, inside a service definition, or inside a nested object such as
environment — fails with a clear error naming the duplicated key (e.g. via object_pairs_hook raising on repeats), and deploy list exits non-zero without enumerating anything.
- Registries without duplicate keys behave exactly as before: the shipped registry (
pkgs/deploy/services.nix via the flake) still validates and lists unchanged; the probe's sane control still exits 0.
- Regression coverage: the malformed-registry flake check (
deploy-list-malformed in lib/default.nix) or an equivalent check exercises at least the duplicate-service-key and duplicate-field cases.
- Existing load errors keep their shape: unreadable file / malformed JSON still exit 1 with the "cannot load registry" message.
Related: #6383 (validate() gaps — duplicate list entries, newline names, host-less healthCheck), #6376 (argument-parser silent input loss in the same file), #5766 (the deploy-tool epic this registry gates). Activitydeveloping-today commented on Nov 5, 2026 dezren39 commented on Nov 5, 2026 🤖 Agent note · state: filed
- Agent: new-issue-creator job (lane A, agent slug
new-issue-creator-code-a)
- Session / ID: cron new-issue-creator-code-a, run 2026-11-05 15:35 CST
- Found via: filed this run
- Task: Filed after verifying on the laptop with probes driving the real
deploy.py (~/git/fleet/probe-deploy-dupkeys/): duplicate JSON keys at service, field, and environment level are silently last-wins at json.load in load_registry (deploy.py:149-151), so an invalid first definition/value is never seen by validate() and deploy list exits 0. Controls (single invalid definition, valid-first orderings, sane registry) all behaved as expected. Dedup: distinct from deploy(deploy.py): validate() accepts shapes its own rules reject — newline service names, duplicate targets/secrets, host-less healthCheck URLs #6383 (duplicate list entries inside validate()) and deploy(deploy.py): arguments after list are silently ignored and a duplicate --registry silently overrides the first — the typo-flag class, in the parser the activation slices will build on #6376 (argument parser).
- Expectation: effort/s — reject duplicate keys at load with a key-named error, keep non-duplicate behaviour identical, add flake-check regression coverage for the duplicate-service-key and duplicate-field cases.
- Links: queue packet to follow in this run (repo-health-code-pilot).
dezren39 commented on Nov 5, 2026 dezren39 commented on Nov 5, 2026 🤖 Agent note · done
Result
- PR fix(deploy): reject duplicate JSON keys at registry load (#6384) #6385 merged (squash, merge commit 5c56f76); issue deploy(deploy.py): duplicate JSON keys in the registry are silently discarded at load — an invalid first definition is never validated #6384 closed by the merge.
load_registry parses with an object_pairs_hook that raises on any repeated key at any nesting level; the error keeps the cannot load registry shape, names the duplicated key, exits 1, and enumerates nothing. Malformed-JSON / unreadable-file errors keep their shape (ValueError now caught; JSONDecodeError is a subclass).
- Regression coverage:
deploy-list-malformed extended with duplicate-service-key and duplicate-field raw-text registries; new deploy-dupkeys-property check runs a property test (random registry trees, stdlib json.loads oracle, duplicate injected at a random object node/depth) after a Codex P1 asked for property-based coverage — dispositioned by fixing in-PR (reply on the review thread) and Codex round 2 completed with no findings.
- Verification (laptop): probes — duplicate service/field/environment keys exit 1 naming the key with empty stdout, sane registry exits 0, single-invalid control unchanged; nix builds of checks
deploy-dupkeys-property, deploy-list-malformed, and deploy-list all pass; the property test finds a counterexample against the pre-fix deploy.py.
- Links: PR fix(deploy): reject duplicate JSON keys at registry load (#6384) #6385, issue deploy(deploy.py): duplicate JSON keys in the registry are silently discarded at load — an invalid first definition is never validated #6384
dezren39 commented on Nov 17, 2026
🤖 Agent note · done (triage — already fixed and closed)
- Agent: queue worker (repo-worker-code), lane any-c
- Session / ID: task 18485
- Found via: queue claim (bulk-intake triage packet, 2026-11-16)
Verdict: already done. Fresh verification this shift (2026-11-17, via gh): issue #6384 is CLOSED with status/done. The fix was worked by task 10786 (lane code-z, 2026-11-05): PR #6385 merged (merge commit 5c56f76) — load_registry in pkgs/deploy/deploy.py now parses with an object_pairs_hook that rejects any repeated key at any nesting level, with regression coverage in deploy-list-malformed and the deploy-dupkeys-property check. Task 18485 completes as already_done on that evidence.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|