Repository navigation
fix(update): stop before restarting when the frontend build fails (#25418) - #28697
Conversation
4b69b17 to
5567e57
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix goes at the root cause (the build result was untyped and its output discarded), all three update paths refuse the restart the same way, and the only take-away is the changed return type, whose callers are all updated here. Notes
[DESIGN-REVIEWED] 95ebe6c Description read[DESCRIPTION-READ] 390eb2a220d383de5f98cecfb94b5bd847d73df969097147490a54a0dcffe5cd 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 blocks. Issue #25418 reports the defect and the tests reproduce it. The fix covers all three update paths, and each extra piece prevents a harm you can name. What this change shipsInventory (9 items) — 9 justifiedIntent: on a source install, an update whose frontend build fails stops before restarting and says where the build output went, instead of restarting onto a new backend with the old dashboard bundle. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 95ebe6c Description read[DESCRIPTION-READ] 75d1420d426a14c58c8ea062919d3b329fbd6801bcc65c2b3a6a492108274769 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: |
5567e57 to
599da58
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
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: |
599da58 to
968cd66
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
968cd66 to
d8a9881
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
ab56c65 to
b291898
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: GPT 6.1's BLOCKING finding on ab56c65 is real. The interrupted path's
|
b291898 to
be1c299
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
be1c299 to
c8429d1
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: GPT 6.1's BLOCKING finding on be1c299 is real: the tail was cut by bytes and lines before
|
c8429d1 to
95ebe6c
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: the Backend Tests (3.12, 5) red on 95ebe6c is not from this diff. It is |
bolichen97
left a comment
There was a problem hiding this comment.
[operator: bolichen97] Approving at this head. I found no breaking issue.
Checked: the CLI update, the dashboard update and the gateway auto-apply all still run the package install after a failed frontend build, and only the restart is refused, so the running gateway stays up and the new tree stays importable. A skipped build still updates and restarts as before. Every in-repo caller of the build functions handles the new return type. The build log is opened safely and its tail is redacted. Windows falls back to the previous behaviour.
Non-blocking notes:
- After a failed build the checkout is already on the new revision, so the next update reports "up to date" and the refusal can persist on an unattended host. A persistent notice, or rebuilding on the next update when the last build failed, would make that state easier to notice.
update_apply.pypassesbuild.failure_message()to the progress card without the outerredact()the dashboard path applies. The tail is already redacted at capture, so this is consistency only.
AI-assisted, approved by bolichen97
Problem / Motivation
Goal: On a source install, an update whose frontend build fails stops before restarting and says where the build output is, instead of restarting onto a new backend that serves the old dashboard bundle.
A source (git checkout) install updates by moving the tree, running
npm ci+npm run buildinwebsite/, reinstalling the package, and restarting. When the build fails, all three update paths (kirocrew update, the dashboard Update button, and the gateway's auto-apply) still reinstall and restart. The backend is then new whilesrc/kiro_crew/static/distkeeps the old bundle. Where the API shapes differ the UI breaks: the reporter saw every new chat crash with React error #31 after seven updates over two weeks. The build output went toDEVNULL, so nothing explained the failure afterwards.Why it matters
Anyone running from a source clone (including hosts that ended up there unintentionally, #25417) can be left with a dashboard that crashes on common actions, with no error in
gateway.logand no hint that the build was the cause. Repeated updates keep restarting onto the mismatch.Not a goal
dashboard/stale_bundle_guard.py) before the restart.static/distand are not affected.What changed (motivation → approach → change)
Symptom: the update restarts after a failed build, and the build's output is lost. Root cause:
build_frontend_sync/build_frontend_asyncreturnedNone, so callers could not tell built, skipped and failed apart, andnpm run build(plus the async install) wrote toDEVNULL.Change:
src/kiro_crew/frontend.py: both helpers return aFrontendBuildResultwithoutcomebuilt,skippedorfailed.skippedkeeps today's non-fatal cases (nowebsite/, nonpm, edition sources absent).failedcovers every attempted build that leaves the previous bundle served: install failed or timed out,npm run buildfailed or timed out, exit 0 with no newindex.html, staging failed, or the staging lock could not be taken. The install and build output now goes to<data home>/logs/frontend-build.log(0600, emptied per run, opened while holding the staging lock).logs/is writable from inside the agent sandbox while this runs in the unsandboxed gateway, sologs/is reached through the shared pinned walk (pinned_fs.create_and_open_dir_pinned) and the file is openedO_NOFOLLOWrelative to it (platform_compat.open_create_or_existing), emptied only afterfstatshows a plain file with one name, and its tail is read back through the same descriptor. A refused destination, or a platform with no pinned walk (Windows,pinned_fs.supports_pinned_walk()false), discards the output as before. In the async helper every log-file step (open, step header, tail read, close) runs through the tracked executor, never on the event loop. This keeps a planted symlink or hard link (for example tosecurity_policy.json) from having that file overwritten. It is a file, not a pipe, so the existing post-kill reap after a timeout still has nothing to drain.failure_message()names the file and its last 20 lines, redacted withkiro_crew.security.redactand capped. Dev Fleet'sbuild_and_stagekeeps discarding output (the newbuild_logparameter defaults toNone).failedbuild (the tree has already moved, and nothing retries the update, so skipping it would leave a checkout whose next restart dies at import), and then refuses the restart:dashboard/handlers/updates_apply.py: after_venv_pip_installsucceeds, callsupdate_ownership.refuse_restart(...), pushes anerrorprogress card with the message, and returns before the restart.slack/gateway_runtime/update_apply.py(auto-apply): logs an error, runs the release install, then callsrefuse_restart(...), pushes theerrorcard when a dashboard is attached, and returns without restarting.cli_server_update.py(kirocrew update): runs the release install, then prints the message and exits 1 without the restart hint.update_ownership.refuse_restartgainsimport_probe_clears(default True). The two frontend-build refusals pass False: the stale-asset watchdog clears a refusal when an import probe of the supervisor's command succeeds, but that probe says nothing about the bundle, so it must not clear a failed-build refusal. Only a later update that completes clears it.src/kiro_crew/security_posture.py:frontend.pynow calls a redactor, so it joinsNON_EGRESS_REDACTION_MODULES(scrubbing at capture, the same reason asplatform/wheel_engine.py); the update paths that show the message are the output boundary.docs/system-specs/modules/cli.md(update step 2),docs/system-specs/modules/slack-gateway.md(restart refusals), anddocs/guides/install.md(what a failed build during an update does and how to finish it).Backwards compatibility
Compatible: the helpers gain a return value; the only callers are the three update paths changed here. A build that is skipped still lets the update continue exactly as before.
Removes nothing: no field, key, function or record is removed; an update that used to restart after a failed build now stops, which is the fix.
Tests
test/test_frontend_build_log.py(new): sync and async builds reportfailedon a build error, an install error and a staging failure,builton a published bundle,skippedwith nowebsite/or nonpm; the install and build output lands inlogs/frontend-build.log(mode0600on POSIX); the failure message names the file and carries a redacted tail; an unopenable log still builds with output discarded; a symlinked log, a hard-linked log and a symlinkedlogs/are each refused, their target left byte-for-byte unchanged, and the output discarded; with no pinned walk no log is opened at all (the log-content tests are skipped there, and the file passes withsupports_pinned_walkforced False);test_the_async_build_touches_its_log_off_the_event_loopchecks the async open and tail read run off the loop thread, and reddens when the open is put back on the loop.test/test_dashboard_updates_coverage_apply.py: a failed build pushes oneerrorcard naming the log, refuses the restart, and never awaits the reinstall or the restart; a skipped build still reinstalls and restarts.test/test_slack_gateway_update_reset.py: the auto-apply does not install or restart after a failed build and records the refusal; a skipped build still restarts.test/test_stale_asset_watchdog.py:test_a_probe_does_not_clear_a_failed_frontend_build_stay_up-- a REENTERABLE probed verdict keeps a failed-build refusal and the watchdog does not fire; the dashboard and auto-apply failed-build tests also check that a probe-style clear leaves their refusal standing.test/test_cli_server_more_coverage.py:kirocrew updatestill installs, then exits 1 after a failed build and prints the log path and tail; a skipped build still reports success.Nonefor the build now return aFrontendBuildResult.Mutation checks, one at a time with a restore between each: replacing each caller's new
if build.outcome == "failed":withif False:reddenstest_a_failed_frontend_build_reinstalls_but_does_not_restart,test_a_failed_frontend_build_installs_but_does_not_restartandtest_frontend_build_failure_installs_then_exitsrespectively; sending the build back toDEVNULLreddens five tests intest_frontend_build_log.py; returningskippedinstead offailedafter a failed build reddenstest_a_failed_sync_build_reports_failed_and_keeps_its_output; opening the log with a plain link-followingos.openand dropping the plain-file check reddenstest_a_symlinked_log_is_refused_and_its_target_left_alone,test_a_hard_linked_log_is_refused_and_its_other_name_left_aloneandtest_a_symlinked_logs_dir_is_refused; letting the probe clear any refusal reddenstest_a_probe_does_not_clear_a_failed_frontend_build_stay_upand both callers' failed-build tests; droppingimport_probe_clears=Falseat either caller reddens that caller's failed-build test; opening by name when no pinned walk exists reddenstest_without_a_pinned_walk_the_output_is_discarded.Proof: not provable -- other: the fix adds the FrontendBuildResult type that the new tests import, so prove.py's whole revert only errors at collection; the per-caller mutations listed above redden the named tests instead.
Manual verification
N/A — unit coverage sufficient: each path's decision is driven through its real update worker with only the build, install and restart stubbed. Not run: a real failing
npm run buildduring a live update, and macOS/Windows (unverified there; on Windows the build output is discarded, as on main, because there is no pinned walk).Related Issues
Closes #25418
Sibling sweep
Swept: git grep -nE "build_frontend_sync(|build_frontend_async(|build_and_stage(" -- src
Sibling: src/kiro_crew/cli_server_update.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/updates_apply.py -- changed here
Sibling: src/kiro_crew/slack/gateway_runtime/update_apply.py -- changed here
Sibling: src/kiro_crew/apps/builtins/dev_fleet/worktree_ops_sync.py -- not affected -- build_and_stage already returns a bool that becomes the child's exit status
Pattern harvest
Rule candidate: review-prompt
Pattern: a step that can fail returns None, so its caller cannot stop the sequence that follows it
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.