Skip to content

fix(wizard): health-check failures no longer kill the configure/onboard/doctor flow - #126758

Merged
steipete merged 2 commits into
mainfrom
steipete/dazzling-visvesvaraya-088ed7
Aug 20, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/dazzling-visvesvaraya-088ed7

Conversation

@steipete

@steipete steipete commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators running the configure wizard's health section, onboarding finalize, or the doctor daemon flow would see the whole CLI die mid-flow when the gateway health check hit a reachable-gateway auth failure (credentials required or rate limited). The process exited with code 1 in the middle of the clack UI — no "health check failed" framing, no docs guidance, no outro, and every remaining wizard step silently dropped. Silent failure on a default onboarding path is the worst bug class per the product doctrine; this was flagged by ClawSweeper on PR #124773 and adjudicated as a separate fix.

Why This Change Was Made

healthCommand has a dual contract: as a standalone CLI command, printing a diagnostic and calling runtime.exit(1) is correct; embedded inside a host flow (wizard/onboard/doctor), the host owns failure reporting. The embedded callers wrapped healthCommand in try/catch, but the exit paths in emitReachableGatewayAuthDiagnostic bypass any catch. The fix adds healthCommandNonExiting in src/commands/health.ts, which runs healthCommand with the host's runtime but with exit trapped into the existing ExitError, so every failure mode funnels through the host's catch. All four embedded call sites (configure wizard, onboarding finalize, doctor daemon flow x2) now use it; each catch skips re-formatting a trapped ExitError (the diagnostic already printed) but still shows the docs note and maps to the failed outcome/outro. Standalone openclaw health behavior is unchanged.

Also fixes a red test on current main: the doctor e2e harness createConfigIO mock lacked configPath, so logConfigUpdated crashed in doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts ("Cannot read properties of undefined (reading 'startsWith')"). Verified failing on origin/main (793669c) before the fix.

User Impact

Operators whose gateway is reachable but rejects health credentials now see the printed diagnostic, a "Health check failed" line where applicable, the health docs note, and a proper wizard outro ("…health check failed") instead of an abrupt process death mid-wizard. Healthy-path behavior is unchanged.

Evidence

  • Regression tests: src/commands/health.test.ts proves the credentials-required path through healthCommandNonExiting throws ExitError, never invokes the host runtime's exit, and still prints the diagnostic lines. src/commands/configure.wizard.test.ts table-drives the failure outro across unreachable/request-failure/trapped-exit and asserts no duplicate failure formatting; verified failing with the guard reverted.
  • Suites: node scripts/run-vitest.mjs green for health.test.ts, configure.wizard.test.ts, doctor-gateway-daemon-flow.test.ts (96 tests), setup.finalize.test.ts + setup.test.ts (108 tests), and the doctor e2e files using the harness. node scripts/check-changed.mjs green (format, tsgo, lint, guards).
  • Live: built dist, ran an isolated dev gateway (own OPENCLAW_STATE_DIR, port 19917, token auth), drove openclaw configure --section health through a real PTY via expect. Failure case renders "Health check failed", the docs note, and the outro with a clean exit; healthy case renders full health output and completes. Gap: the exact credentials-required trigger is not live-inducible on this loopback gateway (loopback trust accepts the probe), so that path rests on the owner unit test above.
  • Autoreview (Codex, gpt-5.6-sol, high): clean — "no accepted/actionable findings", overall 0.97.
  • Production LOC +30 (shared wrapper + guards), tests/test-support +45.

Update: finalize outro records the health outcome (ClawSweeper P1)

ClawSweeper correctly flagged that onboarding finalize still gated its completion outro on the earlier reachability probe, so a reachable gateway with a failed health check could end with the plain success outro. The second commit records the health outcome as its own fact (gatewayHealthCheckFailed) and ends with a dedicated outro ("Onboarding complete, but the gateway health check failed. Fix the issue above, then verify with openclaw health."), with en/zh-CN/zh-TW strings and a regression test asserting the outro after a trapped health exit. Reachability-driven behavior that remains correct (Control UI links, "Gateway: reachable" status, TUI binding) is unchanged.

@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 20, 2026 17:32
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 20, 2026
…xiting mid-flow

healthCommand's reachable-gateway auth diagnostic paths call runtime.exit(1),
which with defaultRuntime hard-kills the hosting configure wizard, onboarding
finalize, or doctor daemon flow mid-render — dropping the failure framing,
docs guidance, and outro. Add healthCommandNonExiting, which traps that
CLI-style exit into ExitError so the host flow owns the outcome, and use it
at every embedded call site.

Also fix the doctor e2e harness createConfigIO mock missing configPath, which
broke doctor.runs-legacy-state-migrations on current main.
@steipete
steipete force-pushed the steipete/dazzling-visvesvaraya-088ed7 branch from d8ffa21 to 946c649 Compare August 20, 2026 17:48
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 20, 2026, 1:54 PM ET / 17:54 UTC.

ClawSweeper review

What this changes

The PR converts embedded health-command exits into caught failures for configure, interactive onboarding, and doctor flows, while preserving standalone openclaw health exits.

Merge readiness

⛔ Blocked by patch quality or review findings - 6 items remain

Keep open: the wrapper correctly prevents a CLI exit from killing host flows, but onboarding finalization still treats the earlier reachability probe as success after a trapped health exit and can finish with a success outro.

Priority: P1
Reviewed head: 946c64985541d309faf78c8f4557c807ca9b55de

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The branch has a focused fix direction and tests, but a P1 onboarding false-success path blocks merge.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body describes an isolated PTY run, but that claim does not cover the newly found onboarding outcome defect.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body describes an isolated PTY run, but that claim does not cover the newly found onboarding outcome defect.
Evidence reviewed 5 items Trapped exit is not recorded as an onboarding failure: The changed onboarding call catches the wrapper's ExitError only to suppress duplicate formatting; it leaves gatewayProbe as the successful pre-check result.
Success path still uses the stale reachability result: Later UI gating and the final outro are driven by gatewayProbe.ok, so an auth-rejected health command can still produce the normal successful completion path.
Current-main behavior explains the regression: Current main invokes healthCommand directly from onboarding; its reachable-auth diagnostic calls runtime.exit(1), so it cannot proceed to a successful outro after this specific failure.
Findings 1 actionable finding [P1] Record trapped health exits before completing onboarding
Security None None.

Live Verification

Command: pnpm openclaw configure --help

Result: PASS (completed)

pnpm openclaw configure --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126758-vwCFZn/target$ pnpm openclaw configure --help
$ node scripts/run-node.mjs configure --help
pnpm openclaw configure --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 104.27 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.6s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4482ms (slowest: built plugin control-plane loads 3490ms)

OpenClaw 2026.8.1 (946c649) — All your chats, one OpenClaw.

Usage: openclaw configure [options]

Interactive configuration for credentials, channels, gateway, and agent defaults

Options:
  -h, --help           Display help for command
  --section ‹section›  Configuration sections (repeatable). Options: workspace, model, web, gateway, daemon, channels, plugins, skills, health (default: [])

Docs: docs.openclaw.ai/cli/configure

runner@runnerv
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Gateway health first checks whether a configured Gateway is reachable, then performs an authenticated health command. Configure, onboarding, and doctor consume those results to decide whether to show recovery guidance, continue setup, or finish successfully.

flowchart LR
  A[Gateway readiness probe] --> B[Authenticated health command]
  B --> C{Standalone or embedded}
  C -->|Standalone| D[Diagnostic and process exit]
  C -->|Embedded| E[Trapped exit failure]
  E --> F[Host records health outcome]
  F --> G[Recovery note or successful outro]
Loading

Before merge

  • Record trapped health exits before completing onboarding (P1) - After healthCommandNonExiting rejects, this catch leaves gatewayProbe.ok from the earlier readiness check intact. The later Control UI gating and final outro therefore follow the success path even though the authenticated health check printed a credentials/rate-limit failure. Record a separate failed health outcome and use it to prevent the successful handoff/outro; add coverage for this path.
  • Resolve merge risk (P1) - Merging as-is lets a default onboarding flow present a successful Gateway/UI completion after an authenticated health check has already failed.
  • Resolve merge risk (P1) - Production code grows by 30 net lines; the shared wrapper is useful across embedded callers, but the onboarding outcome should be absorbed into one explicit recorded health result rather than inferred from reachability.
  • Complete next step (P2) - A narrow, mechanical repair can preserve the wrapper while preventing onboarding from converting a trapped health failure into a successful finish.
  • Improve patch quality - Record the trapped health exit as a failed onboarding outcome.
  • Improve patch quality - Add a setup-finalize regression test that verifies recovery outro and no successful UI handoff after the trapped exit.

Findings

  • [P1] Record trapped health exits before completing onboarding — src/wizard/setup.finalize.ts:590-604
Agent review details

Security

None.

PR surface

Source +37, Tests +37. Total +74 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 5 58 21 +37
Tests 7 46 9 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 104 30 +74

Review metrics

Metric Value Why it matters
Production vs test LOC production +43/-13 (net +30); tests/test support +61/-17 (net +44) The shared wrapper covers four embedded callers, but the positive production delta must also preserve a canonical recorded outcome for onboarding.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-gateway-daemon-flow.test.ts, migration/backfill/repair: src/commands/doctor-gateway-daemon-flow.ts, migration/backfill/repair: src/commands/doctor.e2e-harness.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Record the onboarding health failure (recommended)
    Keep the trapped diagnostic unformatted, but persist a failed health outcome so onboarding cannot reclassify the Gateway as successful or render the normal completion outro.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Track the trapped health exit as a failed health outcome in onboarding finalization, and add regression coverage showing it skips the successful Control UI/completion path.

Technical review

Best possible solution:

Make onboarding own an explicit health-validation outcome distinct from transport reachability, preserve the already-printed diagnostic, and route that outcome through recovery guidance, UI gating, and the final outro.

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

Yes, from source: make the new embedded health wrapper throw ExitError after the initial readiness probe returns ok; onboarding keeps that probe result and reaches its success-controlled UI and outro paths.

Is this the best way to solve the issue?

No. Trapping the exit is the right owner-boundary direction, but onboarding must record health validation separately from simple reachability before it can choose a successful completion path.

Full review comments:

  • [P1] Record trapped health exits before completing onboarding — src/wizard/setup.finalize.ts:590-604
    After healthCommandNonExiting rejects, this catch leaves gatewayProbe.ok from the earlier readiness check intact. The later Control UI gating and final outro therefore follow the success path even though the authenticated health check printed a credentials/rate-limit failure. Record a separate failed health outcome and use it to prevent the successful handoff/outro; add coverage for this path.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 64b0e865df95.

Labels

Label changes:

  • add P1: A default onboarding path can report completion after a rejected authenticated health check.
  • add merge-risk: 🚨 other: The changed setup control flow can falsely report a successful Gateway/UI handoff despite a failed health validation.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body describes an isolated PTY run, but that claim does not cover the newly found onboarding outcome defect.

Label justifications:

  • P1: A default onboarding path can report completion after a rejected authenticated health check.
  • merge-risk: 🚨 other: The changed setup control flow can falsely report a successful Gateway/UI handoff despite a failed health validation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body describes an isolated PTY run, but that claim does not cover the newly found onboarding outcome defect.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/wizard/setup.finalize.test.ts.
  • [P1] node scripts/run-vitest.mjs src/commands/health.test.ts src/commands/configure.wizard.gateway.test.ts.
  • [P1] node scripts/check-changed.mjs.

What I checked:

  • Trapped exit is not recorded as an onboarding failure: The changed onboarding call catches the wrapper's ExitError only to suppress duplicate formatting; it leaves gatewayProbe as the successful pre-check result. (src/wizard/setup.finalize.ts:590, 946c64985541)
  • Success path still uses the stale reachability result: Later UI gating and the final outro are driven by gatewayProbe.ok, so an auth-rejected health command can still produce the normal successful completion path. (src/wizard/setup.finalize.ts:673, 946c64985541)
  • Current-main behavior explains the regression: Current main invokes healthCommand directly from onboarding; its reachable-auth diagnostic calls runtime.exit(1), so it cannot proceed to a successful outro after this specific failure. (src/wizard/setup.finalize.ts:590, 64b0e865df95)
  • Diagnostic-exit provenance: The reachable-gateway authentication diagnostic, including its runtime.exit(1) calls, appears to date to the current-main commit that introduced this behavior. (src/commands/health.ts:91, eb84b56766f5)
  • Sibling coverage is incomplete: The added configure test exercises ExitError and asserts its failed outro, but the onboarding-finalize suite adds no corresponding trapped-exit outcome coverage. (src/commands/configure.wizard.gateway.test.ts:415, 946c64985541)

Likely related people:

  • steipete: Current-main blame attributes the reachable-auth exit path to this contributor, who also authored the proposed host-flow repair. (role: introduced current diagnostic behavior and recent area contributor; confidence: high; commits: eb84b56766f5, 946c64985541; files: src/commands/health.ts, src/commands/configure.wizard.ts, src/wizard/setup.finalize.ts)
  • Vincent Koc: History shows this contributor carried the health snapshot/summary refactor underlying the command’s current health surface. (role: health-subsystem refactor contributor; confidence: medium; commits: 0211407d8a2c, 46f629882b50; files: src/commands/health.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

A reachable gateway whose health check failed still ended onboarding with the
plain success outro because completion gating only read the earlier
reachability probe. Record the health outcome as its own fact and end with a
dedicated outro pointing at openclaw health. (ClawSweeper P1 on #126758.)
@steipete
steipete merged commit 28ec823 into main Aug 20, 2026
235 checks passed
@steipete
steipete deleted the steipete/dazzling-visvesvaraya-088ed7 branch August 20, 2026 18:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 21, 2026
…rd/doctor flow (openclaw#126758)

* fix(wizard): keep embedded health-check failures visible instead of exiting mid-flow

healthCommand's reachable-gateway auth diagnostic paths call runtime.exit(1),
which with defaultRuntime hard-kills the hosting configure wizard, onboarding
finalize, or doctor daemon flow mid-render — dropping the failure framing,
docs guidance, and outro. Add healthCommandNonExiting, which traps that
CLI-style exit into ExitError so the host flow owns the outcome, and use it
at every embedded call site.

Also fix the doctor e2e harness createConfigIO mock missing configPath, which
broke doctor.runs-legacy-state-migrations on current main.

* fix(onboard): reflect a failed health check in the finalize outro

A reachable gateway whose health check failed still ended onboarding with the
plain success outro because completion gating only read the earlier
reachability probe. Record the health outcome as its own fact and end with a
dedicated outro pointing at openclaw health. (ClawSweeper P1 on openclaw#126758.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M 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