Skip to content

fix: show managed update helper startup failures - #181402

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1845
Oct 23, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1845

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Refs #181337. Thanks @Chengmun58 for the report.

What Problem This Solves

When a managed update helper exits before readiness, the Control UI reports only the exit code and asks the user to diagnose it from another terminal. The launcher discarded stderr and deleted the helper's own startup log before retaining its cause.

User Impact

Update history and the local update report now retain bounded, redacted startup diagnostics, including an engine incompatibility or an arbitrary startup exception. The original Gateway keeps serving when handoff fails. The capture must be present in the installed updater; it cannot repair an older updater already running.

Why This Change Was Made

The handoff owner sends stderr to its existing private helper log, then reads at most 8 KiB before cleanup. It retains the first error and final diagnostic lines in the existing 200-character failure facts. Diagnostic capture remains best effort, and the readiness, ownership, and cleanup contracts stay in place. Public support exports retain their existing stricter redaction policy.

The helper starts installed code, not the target package. #180769 already adds the target Node-engine preflight before package staging, after the helper starts. Node 24.21.0 is below the reported target's requirement, but that alone does not establish the cause of the original Windows helper exit. This PR references the issue rather than claiming that unseen startup exception is fixed.

Evidence

  • Both added real-helper regressions fail on the base because the reason is missing. They exercise the update.run handler, detached process, persisted failure facts, and rendered report. Cases cover a multi-line Node engine error and oversized stderr with a synthetic secret.
  • Node and pinned Bun: the complete 26-test report suite passed. The expanded diagnostic cases also passed on the final Bun code.
  • Local live Gateway: an authenticated update.run RPC returned the injected EACCES startup error with the synthetic token redacted. Health was HTTP 200 before and after; the isolated Gateway then shut down cleanly. No installed service was stopped or restarted.
  • Scoped core and Gateway-test typechecks, oxlint, oxfmt, and git diff --check passed. Madge reported zero import cycles.
  • Consumer inventory: 53 files selected by direct imports and the shared test barrel. All 53 files were reached: 1,039 tests passed, 10 existing tests skipped, and one test has the base-confirmed environment failure described below. After that failure stopped shard scheduling, the remaining 15 files passed separately (175 tests; 234.85s).
  • The environment failure is src/cli/update-cli.test.ts → rejects a malformed inferred JSON dev target before running the update: the external TMPDIR has a group-writable ancestor, so the SQLite staging owner emits an additional warning. The same test fails identically on untouched base c65a35325cd00ebbed2094fb353391078b090df3 and passes on this patch with the native private temp directory. No assertion or production behavior was weakened.
  • Existing long-running files (sum of test times): update-command-original-service.test.ts 256.11s; update-managed-service-handoff-recovery-launchd.test.ts 163.66s; update-managed-service-handoff-recovery-systemd.test.ts 153.60s; update-managed-service-handoff-foreground.test.ts 147.27s; update-cli.test.ts 141.55s; update-cli.candidate-activation.test.ts 140.00s. No individual test exceeded 30s. update-command-fresh-preview.test.ts also took 125.28s in the remaining run. Total first-run wall time: 2539.65s.
  • Full check:changed was not run because of its SQLite inventory cost; the scoped checks above were run, and PR CI supplies broad proof. Native Windows execution was not available.
  • Independent Codex review at P0/P1: scoped clean, with no accepted/actionable findings.
Local live proof commands and result

The synthetic preload exits only when Node starts handoff.cjs, emitting an EACCES startup error and a fake token. The RPC driver uses the production callGatewayCli client to call update.run with {} and asserts HTTP health before and after.

HOME="$PWD/.artifacts/l1845/live-home" OPENCLAW_STATE_DIR="$PWD/.artifacts/l1845/live-state" OPENCLAW_GATEWAY_PORT=61890 OPENCLAW_PROFILE=l1845 OPENCLAW_VITEST_RUNTIME=node NODE_OPTIONS="--require=$PWD/.artifacts/l1845/helper-startup.cjs" env -u OPENCLAW_LAUNCHD_LABEL -u XPC_SERVICE_NAME -u LAUNCH_JOB_LABEL -u LAUNCH_JOB_NAME pnpm openclaw --profile l1845 gateway run --allow-unconfigured --bind loopback --port 61890 --token synthetic-l1845-gateway-token
HOME="$PWD/.artifacts/l1845/live-home" OPENCLAW_STATE_DIR="$PWD/.artifacts/l1845/live-state" OPENCLAW_PROFILE=l1845 OPENCLAW_VITEST_RUNTIME=node node --import ./scripts/tsx.mjs .artifacts/l1845/live-rpc.ts
PASS: update.run returned the helper startup error with its token redacted; Gateway health remained HTTP 200.
{"ok":false,"reason":"managed-service-handoff-failed","runId":"ac7ee45b-8152-452d-a3b2-e852cf101533"}

Production delta: +64/-4 lines; tests: +68/-0; docs: +4/-0. The growth is the bounded diagnostic reader and real-process regression fixture; there is no new storage schema, dependency, or configuration option.

Preserve bounded, redacted helper startup diagnostics in update failure checks and reports before cleanup. Keep the serving Gateway and existing handoff ownership unchanged.

Refs #181337. Thanks @Chengmun58 for reporting the missing startup diagnostics.
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 23, 2026 06:04
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T06:09:40.556170Z 4f67243 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 23, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f67243125

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 50 to +51
"handoff-helper-exited":
"The update helper exited before acknowledging the handoff. Run openclaw doctor, then retry openclaw update from an external terminal to inspect its startup failure.",
"The update helper exited before acknowledging the handoff. Check the helper startup diagnostics in this update report, correct the reported problem, then retry the update. The Gateway kept serving.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve a fallback when startup diagnostics are absent

When handoff.log cannot be opened/read or the helper exits without writing a diagnostic (for example, a signal-only exit), readHandoffStartupFailure returns the original error, but this message still tells the user to inspect and correct nonexistent diagnostics. The previous Doctor/external-terminal recovery guidance is therefore lost precisely on the best-effort capture path; retain that fallback here or select the new wording only when a diagnostic fact was captured. This is required so update errors continue to name an actionable next step.

AGENTS.md reference: AGENTS.md:L74-L77

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR retains bounded, redacted managed-helper startup errors in update history and reports before deleting temporary files.

Example: The managed update helper exits with an EACCES startup exception containing token=fixture-private-token.

  • Before: The update report shows only the helper's early exit and discards its startup exception.
  • After: The report retains the EACCES diagnostic, redacts the token, and records that the Gateway kept serving.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful and demonstrated through the shipped Gateway entry point, with one confirmed recovery-message regression; existing fact formats and storage models remain unchanged.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The full PR body supplies shipped CLI Gateway startup and authenticated update.run live output for an injected helper EACCES, confirming redaction and HTTP 200 health before and after; real detached-helper regressions additionally exercise persisted facts and report rendering.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A failed managed update hides the helper's startup exception, leaving users with only an exit code.
Reason: The maintainer-authored direction addresses verified diagnostic loss and correctly references, rather than closes, the broader Windows report.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it addresses a verified diagnostic gap with live evidence, but one focused recovery-guidance defect remains.

Priority: P2
Reviewed head: 4f67243125379f529ffac847772bb0e7df1e9356

Before merge

  • Preserve recovery guidance when startup diagnostics are absent (P2) - If the helper exits before readiness without writing stderr, or its log cannot be read, readHandoffStartupFailure returns the original error without diagnostic facts. This unconditional message nevertheless tells the user to correct startup diagnostics in the report and removes the previous Doctor/external-terminal fallback. The resulting report contains only the early-exit envelope and gives no usable diagnostic next step. Retain the fallback in this description or select diagnostic-specific wording only when useful output was captured, with coverage for an empty or unreadable log.

Findings

  • [P2] Preserve recovery guidance when startup diagnostics are absent — src/infra/update-preflight-details.ts:51
Agent review details

How this fits together

The Gateway's update.run handler launches the installed updater's detached helper; startup failures flow through existing failure facts into update history and local or public reports.

flowchart TD
  A[Control UI update request] --> B[Gateway update.run]
  B --> C[Managed handoff owner]
  C --> D[Detached helper]
  D --> E[Private helper log]
  E --> F[Bounded redacted failure facts]
  F --> G[Update history and reports]
Loading

Technical review

Best possible solution:

Keep diagnostic capture in the existing handoff owner and preserve an actionable recovery fallback when capture produces no useful output.

Do we have a high-confidence way to reproduce the issue?

Current-main source demonstrates the diagnostic loss: stderr is ignored and the helper directory is deleted after readiness failure; the supplied live RPC trace demonstrates capture after the patch, while the original Windows exception remains unknown.

Is this the best way to solve the issue?

Capturing the existing private log before cleanup is a focused repair using established redaction and failure-fact owners; the reader and two regression cases are justified without another lifecycle or storage owner.

Full review comments:

  • [P2] Preserve recovery guidance when startup diagnostics are absent — src/infra/update-preflight-details.ts:51
    If the helper exits before readiness without writing stderr, or its log cannot be read, readHandoffStartupFailure returns the original error without diagnostic facts. This unconditional message nevertheless tells the user to correct startup diagnostics in the report and removes the previous Doctor/external-terminal fallback. The resulting report contains only the early-exit envelope and gives no usable diagnostic next step. Retain the fallback in this description or select diagnostic-specific wording only when useful output was captured, with coverage for an empty or unreadable log.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d09e172f0b5a.

Provenance checked

  • Helper readiness, stderr, and cleanup keeps the original intent (fix(infra): verify managed update handoff startup #103278: Verify actual helper readiness before allowing Gateway shutdown and remove sensitive temporary files after failed startup; later PostgreSQL work retained separate IPC.)
  • Public helper-exit recovery guidance changes intended behavior with a stated reason (800fce2: Retain a bounded failure cause and actionable next step instead of opaque update failures.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/gateway/server-methods/update-handoff-failure.test.ts --maxWorkers=1
  • pnpm test src/infra/update-managed-service-handoff-lifecycle.test.ts --maxWorkers=1
  • node scripts/run-oxlint.mjs --tsconfig tsconfig.json src/infra/update-preflight-details.ts src/gateway/server-methods/update-handoff-failure.test.ts
  • node_modules/.bin/oxfmt --check src/infra/update-preflight-details.ts src/gateway/server-methods/update-handoff-failure.test.ts
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a1e75e0 adds src/infra/update-managed-service-handoff.ts:784 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a1e75e0c612e; files: src/infra/update-managed-service-handoff.ts)

PR surface

Source +60, Tests +68, Docs +4. Total +132 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 64 4 +60
Tests 1 68 0 +68
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 136 4 +132

Review metrics

Metric Value Why it matters
Production versus test delta Production +64/-4; tests +68/-0 Growth is justified by bounded diagnostic capture and two distinct real-process cases covering multiline errors and oversized output with secret redaction.

Labels

Label changes:

  • add P2: This PR improves diagnosis of failed managed updates while retaining the serving Gateway; the unresolved Windows update failure remains tracked separately.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This PR improves diagnosis of failed managed updates while retaining the serving Gateway; the unresolved Windows update failure remains tracked separately.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 23, 2026, 2:19 AM ET / 06:19 UTC.

@steipete
steipete merged commit 60546de into main Oct 23, 2026
219 of 224 checks passed
@steipete
steipete deleted the upd/upd-l1845 branch October 23, 2026 06:27
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…1402)

When the managed-service update handoff helper exited before signaling readiness, the launcher discarded its stderr and deleted its startup log before recording the cause, so users (e.g. Windows Control UI updates) only saw 'inspect its startup failure from an external terminal'. The launcher now captures a bounded 8 KiB tail, redacts it with the existing redaction helpers before cleanup, and includes the bounded diagnostic in the failure check and update report. Refs openclaw#181337, reported by @Chengmun58.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant