GeezerVison is showing github.com — worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback · Issue #6394 · developing-today/code
worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback #6394Descriptionworktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, and wrong-shaped config crashes with a raw traceback
infra/worktree-reaper/bin/worktree_reaper.py is the tool that deletes fleet worktrees (git worktree remove + git branch -d) on a timer, gated by the safety rules in its header. Its config — the main config.json and the <state_dir>/config.local.json overlay that install-units.sh uses to denylist the install tree — is merged in load_config (worktree_reaper.py:99–139) with no validation of any kind: no shape check, no known-key check, no type check. main calls it unguarded (:533).
Verified on the laptop at origin/main cb8eee8d68 (script extracted verbatim; probe ~/git/fleet/probe-reaper-config, driving the real load_config and the real binary):
- Typo'd keys are silently accepted, and the denylist silently vanishes. Config
{"deny_path": ["/home/user/git/important"], "quiet_hour": 24} loads OK; the effective config keeps deny_paths == [] and the default quiet_hours == 6, plus two stray keys nothing reads. The same holds in the overlay ({"deny_path": [...]} → deny_paths == []). For a deletion tool, a one-character typo in a deny key converts an explicit "never reap this" into no protection at all, with no message anywhere.
deny_paths as a string silently disarms the check. {"deny_paths": "/home/user/git/important"} loads OK and is kept verbatim; is_denied (:221) then iterates the string character by character, deriving 24 nonsense one-character "paths" — the intended path is never denied and nothing complains. (deny_names as a string similarly turns :229's membership test into a substring test.)
- Wrong-shaped config crashes cryptically. A top-level JSON list or string fails with
ValueError: dictionary update sequence element #0 has length 10; 2 is required — a message that never mentions the config file or that an object was expected. A top-level list in the overlay fails with AttributeError: 'list' object has no attribute 'items' (:122–139).
- Malformed JSON crashes with a raw traceback. Running the real binary with
--config bad.json (contents {oops) exits 1 with an uncaught json.decoder.JSONDecodeError traceback from main → load_config (:533) — no worktree-reaper: cannot load config … style error, and no run record is written to the state dir's runs/ log, so the failure is invisible to the tool's own audit trail.
- Type errors pass load and explode mid-run.
{"quiet_hours": "6"} is accepted verbatim; the run only fails later at the quiet gate (:455, now - cfg["quiet_hours"] * 3600) with TypeError: unsupported operand type(s) for -: 'int' and 'str' — after discovery/fetch work has begun, reported (if at all) as a per-tree anomaly rather than a config error.
Why it matters
Every other gate in this tool is written fail-closed (a failed fetch skips the primary, an unscannable /proc is #5740, the kill switch exits 0) — but the config that parameterizes those gates, including the operator's explicit denylist, is trusted blindly. The failure modes above split into the two worst kinds for a destructive tool: silent weakening (cases 1–2: the run proceeds and deletes, minus the protection the operator wrote down) and opaque crashing (cases 3–5: the timer unit fails with a traceback that names neither the file nor the key, and the run-log audit trail has no entry). The overlay case is not hypothetical configuration drift: the overlay is a generated file whose entire purpose is to denylist the install tree.
Distinct from #5946 (the reaper's test suite is run by no workflow — CI wiring) and #5740 (fail-closed when /proc cannot be scanned). Sibling pattern in a different tool: #6388 (deploy validate() crashing on unhashable values instead of reporting them).
Acceptance criteria
load_config validates both the main config and the overlay before anything is reaped: top level must be a JSON object; unknown keys are rejected (or at minimum reported loudly by name — rejection preferred, matching the fail-closed posture); the known keys are type-checked (deny_paths/deny_prefixes/deny_names/primaries/generated_dirt_* lists of strings, quiet_hours/max_removals numbers, fetch a boolean, path settings strings).
- Any config problem — malformed JSON, wrong shape, unknown key, wrong type — aborts the run before discovery/removal with a single clear error naming the file, the key where applicable, and what was expected; exit non-zero; no Python traceback.
- The valid-config behavior is byte-identical: the committed
config.json, the install-units.sh overlay merge (deny lists union, scalars override), CLI overrides (--quiet-hours, --max-removals, --no-fetch), and the existing test suite (infra/worktree-reaper/tests/test_worktree_reaper.py, 8 tests) all behave exactly as before.
- Regression tests in that suite cover each verified case above: typo'd deny key in config and in overlay,
deny_paths as a string, top-level list/string in config and overlay, malformed JSON, and string quiet_hours — each asserting the clean, naming-the-file error.
Activitydeveloping-today commented on Nov 5, 2026 dezren39 commented on Nov 5, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (new-issue-creator-code-b, Lane B)
- Session / ID: cron new-issue-creator-code-b run 2026-11-05 16:50 CST
- Found via: filed this run
- Task: Filed after verifying on the laptop at origin/main cb8eee8 (probe ~/git/fleet/probe-reaper-config, real load_config + real binary): typo'd deny_path/quiet_hour keys silently accepted with the denylist dropped in both config and overlay; deny_paths as a string iterated per-character by is_denied; top-level list/string and malformed JSON crash with raw tracebacks (real binary exit 1); string quiet_hours accepted at load then TypeErrors at the quiet gate.
- Expectation: effort s — triage confirms the reject-vs-warn shape for unknown keys and routes load-time config validation plus regression tests.
- Links: probe ~/git/fleet/probe-reaper-config (laptop); distinct from ci(worktree-reaper): test_worktree_reaper.py is run by no workflow — the destructive reap gates are verified nowhere #5946 (CI wiring) and worktree-reaper: fail closed when /proc cannot be scanned before removal #5740 (/proc fail-closed)
dezren39 commented on Nov 5, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 11, 2026 🤖 Agent note · triaged (inline, per runbook §1c) — fix proceeding in this same session
- Agent: queue worker (repo-worker-code), lane code-w
- Session / ID: task 10809
- Found via: queue claim
- Verdict: REAL AND CURRENT. Fresh verification 2026-11-11 at current main:
load_config in infra/worktree-reaper/bin/worktree_reaper.py (now at bin/, lines 145-183) still performs no validation — cfg.update(json.load(fh)) unguarded, overlay merged via local.items() unguarded, no known-key or type checks, and main still calls it unguarded (line 716). All five failure modes from the issue body stand (typo'd deny keys silently disarm the denylist; string-typed deny_* iterate/substring; wrong-shaped top level crashes cryptically; malformed JSON is a raw traceback; wrong-typed scalars explode mid-run).
- Work kind: task/small-fix (the packet's own scope: load-time validation + regression tests). Priority: priority/normal (retained). Effort: effort/s. Kind: kind/bug (retained).
- First concrete step: add a
validate_config pass in load_config for both files (known keys = DEFAULT_CONFIG keys; per-key types from the defaults; top level must be an object; JSON/read errors wrapped in a ConfigError naming the file), surface it in main as worktree-reaper: cannot load config … with a nonzero exit, and add regression tests in infra/worktree-reaper/tests/test_worktree_reaper.py for each invalid case from the issue.
- Acceptance check: each invalid case in the issue yields the clean naming-the-file error (no traceback, no silent disarm); valid config + overlay merge behavior unchanged (existing suite green).
- Links: task 10809 · issue worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback #6394
dezren39 commented on Nov 11, 2026 🤖 Agent note · done
- Agent: queue worker (repo-worker-code), lane code-w
- Session / ID: task 10809
- Found via: queue claim (inline triage + fix in one session, runbook §1c)
- Task: task 10809 DONE fixed_merged — PR fix(worktree-reaper): validate config at load (#6394) #8482 merged (merge commit 66802e2); issue worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback #6394 auto-closed.
- What landed:
load_config validates both the config file and the install overlay at load (_load_json_object + validate_config in infra/worktree-reaper/bin/worktree_reaper.py): unknown keys refused (a typo'd deny key can no longer silently disarm the denylist), per-key types enforced from DEFAULT_CONFIG, top level must be a JSON object, read/JSON errors raise a ConfigError naming the file, and main prints worktree-reaper: cannot load config: … with exit 2 — no traceback, no mid-run explosion. Valid config + overlay merge behavior unchanged.
- Tests: full suite on the laptop — 28 tests OK, including 8 new
ConfigValidationTests covering every failure mode in the issue; the real binary was also driven directly on malformed JSON and the typo case (clean error, exit 2).
- Codex: no Codex review had arrived on PR fix(worktree-reaper): validate config at load (#6394) #8482 within ~4.5 minutes of opening (fleet CI/review queue stall); merged on the standing criteria with targeted tests green — any late Codex finding routes through the normal PR follow-on.
- Links: task 10809 · issue worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback #6394 · PR fix(worktree-reaper): validate config at load (#6394) #8482
dezren39 commented on Nov 11, 2026 🤖 Agent note · done (already_done)
- Agent: repo queue worker, lane code-f (repo-worker-code)
- Session / ID: cron repo-queue-worker-shift-f run 2026-11-10; task 14854
- Task: task 14854 (small_fix, triage follow-on from task 10809) for issue worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback #6394. Fresh check this shift: issue worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback #6394 is CLOSED (COMPLETED, 2026-11-11T03:11:24Z). The fix landed minutes before this follow-on was even created: task 10809 (lane code-w) triaged the issue inline and fixed it in the same session — PR fix(worktree-reaper): validate config at load (#6394) #8482 merged (merge commit 66802e2), adding
_load_json_object + validate_config to load_config in infra/worktree-reaper/bin/worktree_reaper.py (unknown keys refused, per-key types from DEFAULT_CONFIG, top-level object enforced, file-naming errors) with the regression coverage the acceptance names. This follow-on (created 03:12:05Z) raced that completion.
- Outcome: task 14854 completes as already_done; nothing remains to implement.
- Links: task 14854 · task 10809 · issue worktree-reaper: config is never validated — typo'd deny_* keys and string-typed values silently disarm the denylist, wrong-shaped config crashes with a raw traceback #6394 · PR fix(worktree-reaper): validate config at load (#6394) #8482
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|