Repository navigation
fix: report a lifecycle script that cannot start as failed - #34507
Conversation
run_lifecycle_script returns {output, failed}, and every caller acts
on failed: enable rolls the app back, an update notes it, and
uninstall and teardown carry on. When the spawn itself raised (no
shell, EAGAIN, ENOMEM), the OSError escaped instead. Teardown caught
it, but enable was left with the backend started and no rollback, an
update re-run failed a route that must not fail, and uninstall
stopped after its crons were already removed.
Catch the spawn's OSError and return a failed result, so each caller
takes the failure path it already has.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The fix sits in the shared helper, which already promises a Notes
[DESIGN-REVIEWED] a20e80d Description read[DESCRIPTION-READ] 6cf68728b1d052c35d143ee85641a31ad64e3b79c5f6c7a0a8702d90912bd900 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 Nothing to check. What this change shipsInventory (2 items) — 2 justifiedIntent: when an app script can't even start, its enable, update or uninstall should finish or roll back cleanly instead of stopping half done. FIX.
[FIRST-PRINCIPLES-REVIEWED] a20e80d Description read[DESCRIPTION-READ] 9287a4bc2b34b67e6aef6dbb9ad014d72542fcd527439224fa040e5d18fb4ed6 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: returns a failed result when a lifecycle script's process cannot be started, so callers roll back as for any failed script; regression test added.
bolichen97
left a comment
There was a problem hiding this comment.
Approving a20e80d. run_lifecycle_script now catches an OSError from create_subprocess_limited (no shell, EAGAIN, ENOMEM). It logs one warning and returns {"output": "script could not be started: ...", "failed": True}, the result shape every caller already handles. Before, the raise skipped that handling: an enable was left half done, and an uninstall stopped after its crons were already gone (#34502).
Nothing new is refused. A spawn that fails was already a failure. Now it goes down the existing failed path instead of escaping. The test covers FileNotFoundError and BlockingIOError and checks that the sandbox wrapper's temp file is still cleaned up. No regex. All 98 checks are green. Auto-merge is left to the author.
Problem / Motivation
Goal: An app lifecycle script whose process cannot be started is reported as a failed script, so enable rolls back and uninstall finishes instead of stopping half done.
run_lifecycle_scriptreturns{output, failed}, and every caller acts onfailed. When the spawn itself raisedOSError(no/bin/bash,EAGAINfrom a process limit,ENOMEM), the error escaped instead. Enable was left with the backend started and no rollback, the post-updateonEnablere-run failed a route that must not fail, and uninstall stopped after its crons were already removed. Teardown already caught it.Why it matters
These are the moments a host is most likely to be short of processes or memory. An uninstall that stops after deleting the app's crons leaves an app that is still installed but no longer runs its schedules, and every retry stops at the same place.
Not a goal
TypeError,ValueErrororRuntimeErrorfrom the spawn helper; those are not raised for a script that merely cannot start.What changed (motivation → approach → change)
Symptom: enable answers 500 with the app half enabled; uninstall answers 500 with its crons gone. Cause:
create_subprocess_limitedraisingOSErrorwas not caught inrun_lifecycle_script, so it skipped thefailedpath every caller already has. Change: catchOSErroraround the spawn only, log it, and return{"output": "script could not be started: ...", "failed": True}. The existingfinallystill removes the sandbox wrapper's temp file.Backwards compatibility
Compatible: a script that starts behaves exactly as before; a spawn that used to raise now returns the failed result the function already documents.
Removes nothing: no input, key, route or behavior is taken away.
Tests
test/test_lifecycle_script_spawn_failure.py: a spawn that raisesFileNotFoundErrororBlockingIOErrorreturnsfailed: Truewith a "could not be started" message, and the sandbox wrapper's temp file is still removed. Both cases fail on main (the OSError escapes) and pass with the fix. 1,055 tests in the 41 lifecycle, enable, uninstall and teardown test files pass.Proof: not provable -- other: prove.py ended inconclusive (collection-only error); run by hand against the origin/main copy of lifecycle_scripts.py, both new cases fail and pass with the fix.
Manual verification
N/A — unit coverage sufficient: the change is one except clause around the spawn, exercised directly by the test.
Related Issues
Fixes #34502
Open PR #10599 also edits
lifecycle_scripts.py; it already conflicts with main, so whichever lands second rebases.Sibling sweep
Swept: git grep -n "run_lifecycle_script(" -- src/kiro_crew/
Sibling: src/kiro_crew/apps/teardown.py -- not affected -- already catches an exception from the runner
Sibling: src/kiro_crew/apps/routes_uninstall.py -- not affected -- fixed through the shared runner, no change needed here
Sibling: src/kiro_crew/apps/routes_lifecycle.py -- not affected -- fixed through the shared runner, no change needed here
Pattern harvest
Not generalizable: the defect is one helper that promises a result dict but let its spawn error escape; the fix lives in that helper.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the Apache-2.0 license of this project.