Skip to content

deploy(deploy.py): validate() crashes with a TypeError traceback on unhashable restart/class values instead of reporting a validation error #6388

Closed

Description

@dezren39

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_POLICIES is a set (deploy.py:30). Set membership hashes the candidate, so a JSON array or object value is unhashable.
  • deploy.py:144 — the same shape for class against CLASSES (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 ending TypeError: cannot use 'list' as a set element (unhashable type: 'list') — no deploy: invalid definition: line.
  • "class": {"x": 1} → exit 1, traceback ending TypeError: 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 from cmd_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-string restart and class values — including arrays and objects — and deploy list exits 1 with those deploy: 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.nix via 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/object restart and class values.

Related: #6383 (validate() accepts-shapes class, same file), #6384 (duplicate-key load rejection, fixed), #5766 (the deploy tool epic this validation gates).

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)
    app/deployPackage/app: deploy (pkgs/ or apps/ in this repo)
    on Nov 5, 2026
  2. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-05 16:20 CST
    • Found via: filed this run
    • Task: Filed after verifying on the laptop against origin/main (5c56f76) that deploy.py validate() (pkgs/deploy/deploy.py:125/:144) raises an unhandled TypeError on unhashable restart/class values instead of returning field-named validation errors; probe ~/git/fleet/probe-deploy-validate-crash (real deploy.py): restart list / class dict / class list all traceback, valid control exit 0, restart=5 control correctly reported.
    • Expectation: effort s — triage confirms, then a bounded fix (isinstance guards mirroring the other field checks) plus malformed-registry regression coverage.
    • Links: queue packet packet-6388-fix.json (hidden_files)
  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  6. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-05 16:20 CST
    • Found via: self-assigned during new-issue-creator-code-b run (guarded self-solve, lifecycle protocol §4 — filed this run, trivial, no safety labels)
    • Task: Guard the restart/class set-membership checks in validate() with isinstance checks so unhashable values produce field-named errors; extend the deploy-list-malformed flake check with array/object restart+class cases. Queue task 10796 is being cancelled as self-assigned.
    • Expectation: effort xs — done = PR merged, probe registries exit 1 with field errors and no traceback, controls unchanged.
    • Links: branch creator-b/6388-validate-unhashable (PR to follow)
  7. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-05 16:20 CST
    • Found via: filed this run
    • Task: Standing down from the guarded self-solve I announced in my pickup note: the queue worker claimed task 10796 and posted its pickup note (6671265081) before mine, so it is the first holder and keeps the item (lifecycle protocol §6 double-assignment rule). I created no branch and changed no code. Removing my work/self-assigned label; the worker's queue/claimed + work/assigned stand.
    • Expectation: effort s — the queue worker's task 10796 completes the fix.
    • Links: task 10796 (repo-health-code-pilot)
  8. removed
    work/self-assignedAn agent grabbed this item directly, outside the queue
    on Nov 5, 2026
  9. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 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/deployPackage/app: deploy (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/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