Repository navigation
fix(apps): start the gateway when an app pidfile row is not an object - #29159
Conversation
The startup stale-reap reads app_backends.pids.json and calls .get() on
every row, catching only TypeError and ValueError. A row that is not an
object, such as {"some-app": 4242} or null from a hand edit, raised
AttributeError out of dashboard startup, so the gateway crash-looped on
every restart and never repaired the file.
Drop such a row like an unparseable pid, in the scan and in the final
merge, as the other pidfile readers already do.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix handles the bad row in the one reader that crashed and drops it through the existing handled-row merge, and no other reader depends on such rows. [DESIGN-REVIEWED] 3c81577 Description read[DESCRIPTION-READ] 5b690da1ca0c64918d19340dc13918319afe2a7cfbde62f2df8cbb2c4289edb0 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix removes the startup crash reported in #29156. One note: the guard sits in the reaper, not in the pidfile reader whose type is wrong. Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: keep the gateway starting when one app-pidfile row has been hand-edited into a non-object. FIX.
[FIRST-PRINCIPLES-REVIEWED] 3c81577 Description read[DESCRIPTION-READ] a5cd704803cdbac65da0a9b8fa8df9ff624bdf246b1138b8af2408a5fa3bc5ec That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: the stale app-backend reaper skips a pidfile row that is not an object instead of raising on every gateway start; adds a parametrized test.
Problem / Motivation
Goal: The gateway starts even when one row of
app_backends.pids.jsonis not an object, instead of crash-looping on every restart.On every start,
_reap_stale_app_backendsinsrc/kiro_crew/apps/backend_runtime/stale_reap.pycallsentry.get("pid")on each pidfile row and catches onlyTypeError/ValueError. A row like{"some-app": 4242}or{"some-app": null}raisesAttributeErrorout of dashboard startup, which nothing on that path catches. The file is reread and never repaired, so every restart fails the same way.Why it matters
A gateway that will not start takes the dashboard, channels and crons down with it, and the cause is a one-line edit in a state file most people never look at.
Not a goal
What changed (motivation → approach → change)
Symptom:
AttributeErrorat startup. Root cause: the reap assumed every row is a dict. Change: a row that is not a dict is recorded as handled and skipped in the scan, exactly like a row whose pid does not parse, so the final merge drops it. The final merge callswindows_tree_cleanup_pendingonly for dict rows, so it no longer calls.geton a non-dict. The other readers of this file (_forget_app_pid_if,retire_windows_app_tracking, the port lookup) already checkisinstance(entry, dict).Backwards compatibility
Compatible: every writer (
_record_app_pid) writes dict rows, which take the same path as before; only rows that crash startup today are dropped.Removes nothing: the dropped rows name no process the reaper can identify; no field or path is taken away.
Tests
test_reap_drops_a_row_that_is_not_an_object(int, null, string, list): the reap returns 0, does not raise, and the row is gone from the pidfile afterwards.All four cases fail on main with
AttributeError. The app-backend stale-reap, composition contract, characterization, boot coverage, lenient-read ratchet, Windows cleanup and spawn-env suites pass: 645 tests.Proof: not provable -- other: prove.py mutated run errors at test collection; reverting stale_reap.py to main by hand fails all four cases with AttributeError
Manual verification
N/A — unit coverage sufficient: the test writes the malformed rows to the real pidfile path and runs the real reap.
Related Issues
Fixes #29156
Overlaps #13650 (another author, conflicting since 2026-10-29), which edits the final merge of the same function but does not handle non-object rows.
Sibling sweep
Swept: git grep -nE "_read_pidfile()|entry.get("(pid|start_time)"" -- src/kiro_crew/apps/backend_runtime/
Sibling: src/kiro_crew/apps/backend_runtime/stale_reap.py:_reap_stale_app_backends final merge -- changed here
Sibling: src/kiro_crew/apps/backend_runtime/pidfile.py:_forget_app_pid_if -- not affected -- already checks isinstance(entry, dict)
Sibling: src/kiro_crew/apps/backend_runtime/ports.py:recorded_backend_port -- not affected -- already checks isinstance(entry, dict)
Pattern harvest
Rule candidate: review-prompt
Pattern: a reader that validates only the top level of a hand-editable JSON file and then calls methods on each value crashes on one bad row; check each row type where it is read.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the Apache-2.0 license of this project.