Repository navigation
Description
deploy(deploy.py): validate() crashes with a TypeError traceback on unhashable restart/class values instead of reporting a validation error
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". For two fields, a wrong-typed value does not get a field report at all — validate() itself raises, deploy list dies with an unhandled traceback, and no validation errors (including unrelated, correctly-detectable ones in other services) are ever printed.
Verified on the laptop against origin/main (5c56f76; the file at the laptop primary's HEAD is identical for these lines) with a probe driving the real deploy.py against hand-written registries (probe: ~/git/fleet/probe-deploy-validate-crash/ on the laptop):
The defect
- deploy.py:125 —
if "restart" in defn and defn["restart"] not in RESTART_POLICIES:—RESTART_POLICIESis aset(deploy.py:30). Set membership hashes the candidate, so a JSON array or object value is unhashable. - deploy.py:144 — the same shape for
classagainstCLASSES(a set, deploy.py:29).
Every other field check in validate() guards with isinstance(...) before use (e.g. ports requires isinstance(p, int), healthCheck requires isinstance(hc, str) before startswith); the two set-membership checks are the only ones that consume the raw value unguarded.
Observed behavior (real deploy.py, probe registries)
- Valid control registry → exit 0, normal table.
"restart": ["always"]→ exit 1 with an unhandled traceback endingTypeError: cannot use 'list' as a set element (unhashable type: 'list')— nodeploy: invalid definition:line."class": {"x": 1}→ exit 1, traceback endingTypeError: cannot use 'dict' as a set element (unhashable type: 'dict')."class": ["systemd"]→ same list crash."restart": 5(hashable but wrong) → correctly reported: exit 1,deploy: invalid definition: service 'svc': restart must be one of …— so the crash is specific to unhashable JSON values (arrays/objects), the exact shapes a hand-authored or generated registry typo produces.- Because the exception escapes
validate()(called fromcmd_list, deploy.py:167;main()catches only load errors), one crashing service also suppresses the field reports for every other service in the same registry: the registry author gets a Python traceback pointing into the validator instead of the list of what's wrong with their definitions.
Why it matters
validate() is the stated oracle that every later #5766 slice trusts (renderers and activation consume class/restart verbatim). A validator that crashes on malformed input inverts its job: the malformed registries are precisely the ones it exists to explain. The traceback also leaks implementation detail (set internals) as the only diagnostic, in a CLI whose other failure paths (cannot load registry, per-field invalid definition: lines) are deliberately clean.
Distinct from #6383 (same file): that issue is validate() accepting invalid shapes with exit 0 (newline names, duplicate targets/secrets, host-less healthCheck). This one is validate() crashing on invalid shapes — opposite failure mode, different lines, different fix.
Acceptance criteria
validate()returns field-named errors (existing style) for non-stringrestartandclassvalues — including arrays and objects — anddeploy listexits 1 with thosedeploy: invalid definition:lines and no traceback.- A registry mixing a crashing-shape service with another service's ordinary error reports both services' errors in one run.
- Sane controls unchanged: the shipped registry (
pkgs/deploy/services.nixvia the flake) still validates; a hashable wrong value ("restart": 5,"restart": "sometimes") still gets the existing "must be one of" error. - Regression coverage: extend the malformed-registry flake check (
deploy-list-malformed, lib/default.nix) or add an equivalent case exercising array/objectrestartandclassvalues.
Related: #6383 (validate() accepts-shapes class, same file), #6384 (duplicate-key load rejection, fixed), #5766 (the deploy tool epic this validation gates).
Activity
developing-today commentedon Nov 5, 2026
CODE-1903
dezren39 commentedon Nov 5, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 5, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 5, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 5, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 5, 2026
🤖 Agent note · done