Skip to content

fix(cli): show the gateway health reason in status --deep - #196073

Closed
wangmiao0668000666 wants to merge 7 commits into
openclaw:mainfrom
wangmiao0668000666:fix/status-deep-health-error
Closed

wangmiao0668000666 wants to merge 7 commits into
openclaw:mainfrom
wangmiao0668000666:fix/status-deep-health-error

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw status --deep prints only The CLI command failed. For help, run openclaw doctor. when the Gateway is unreachable, hiding the actual health reason. The reason (Gateway is unreachable, or the probe error from a failing health check) was only visible with --json.

User Impact

User impact: status --deep now prints the real health reason plus a diagnostic recovery step (Run openclaw gateway status --deep for gateway diagnostics.) instead of the generic failure line, with the same exit code 1. The step is a diagnostic command that the service owner never refuses and that applies to local and remote targets alike. --json output keeps the stable probe-error message and the exit code is unchanged; no new wording in machine output.

Why This Change Was Made

The deep status path surfaces a failed gateway health probe by throwing a bare Error, which the CLI failure handler classifies as unexpected and replaces with the generic line in human output. Throwing an ExpectedCliError instead lets the human output carry the health reason plus a recovery step, matching the actionable-error contract and what the JSON path already reports. The step is deliberately a diagnostic command rather than a lifecycle command: gateway start/gateway install can be refused by the service owner (for example under an external supervisor), so deriving eligibility from the gateway mode or installation snapshot would recommend commands that are not reliably available. A diagnostic next step needs no such policy and is never refused.

Evidence

Discriminating regression (src/commands/status.scan-failure.test.ts, status --deep gateway health failures > reports the gateway health reason with a diagnostic recovery step):

  • BASE (throw new Error(health.error)): both local and remote cases fail — rejection is a plain Error, not an ExpectedCliError.
  • HEAD (this change): 8/8 tests in the file pass for both a local and a remote unreachable target.

Real CLI proof through the supported shipped launcher (node openclaw.mjs, built dist, Node 24, isolated HOME, no Gateway running), same build with only the throw changed:

Before (base):

$ openclaw status --deep; echo $?
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
1

After (head):

$ openclaw status --deep; echo $?
Gateway is unreachable
Run `openclaw gateway status --deep` for gateway diagnostics.
1

--json machine output is unchanged (the probe error alone, { "ok": false, "error": { "type": "cli_error", "message": "Gateway is unreachable" } }).

The new first-party audit mock carries a mock-isolation annotation explaining why the real security audit must stay outside this fixture (the deep-status regression only asserts the gateway health failure path).

Test-line budget: 61 added lines, allocated in config/test-lines-allocations/status-deep-health-reason.txt.

Maintainer options

Scope and alternatives

This is a narrow single-file change plus its regression test; the TTL-free behavior, JSON schema, and exit codes are unchanged.

Alternatives considered:

  • Keeping the bare throw: leaves the health reason hidden in human output.
  • Wrapping at the CLI boundary: the ExpectedCliError contract already exists for exactly this and is what sibling commands use.
  • Human-only recovery text: kept the machine output as the stable probe error so JSON consumers see no wording change.
  • Recommending gateway start/gateway install: rejected because those commands can be refused by the service owner (external supervisor, no installed service), so the hint must not assume either is permitted; a diagnostic command needs no eligibility policy.

status --deep surfaces the gateway health probe failure by throwing a bare
Error, which the CLI failure handler replaces with the generic "The CLI
command failed." line and hides the real reason (e.g. "Gateway is
unreachable"). Throw an ExpectedCliError instead so the human output carries
the health reason, matching the JSON path and the error-classification
contract used by other commands.
@clawsweeper

clawsweeper Bot commented Nov 9, 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.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Nov 9, 2026
@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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Show the Gateway health failure reason and a diagnostic next step when human-readable status --deep fails.

Example: Run openclaw status --deep with no Gateway running.

  • Before: The CLI prints a generic command failure and exits 1.
  • After: The CLI prints “Gateway is unreachable” and recommends openclaw gateway status --deep, retaining exit code 1.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused diagnostic repair with shipped-entry-point proof, preserved error semantics, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied built-CLI transcript exercises status --deep through openclaw.mjs on Node 24 with isolated HOME and no Gateway, showing the health reason, diagnostic next step, and exit 1; subsequent commits leave the production behavior unchanged.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users see a generic CLI failure instead of the Gateway health reason when deep status encounters an unreachable Gateway.
Reason: The change makes an existing diagnostic failure understandable using the established CLI contract and introduces no new setting or behavior policy.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current diagnostic bug with a focused change; no blocking defects remain, and the reviewed head has a successful CI gate.

Priority: P2
Reviewed head: 015da63992c496e4b9feac56c29f7b19491c6c05

Before merge

None.

Findings

None.

Agent review details

How this fits together

The status command consumes Gateway scan and health results, then passes expected failures to the shared CLI renderer for human-readable output.

flowchart TD
  A[Status CLI] --> B[Gateway scan]
  B --> C[Runtime health snapshot]
  C --> D[Expected CLI error]
  D --> E[Shared failure renderer]
  E --> F[Reason and diagnostic command]
Loading

Technical review

Best possible solution:

Use the existing expected-error renderer to expose the health reason with a target-neutral diagnostic command.

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

Current-main source establishes the bare-error path, and the contributor supplies a discriminating before/after shipped CLI transcript; no target code was executed during this review.

Is this the best way to solve the issue?

The patch restores actionable error reporting through the existing owner and preserves the intentional failure behavior without adding lifecycle policy.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Text status health-failure handling keeps the original intent (4e4f76f: Preserve deep health failures rather than reporting apparent health, while keeping JSON failures structured.)
  • Existing scan-failure test coverage keeps the original intent (test(core,plugins,ui): remove low-value tests (batch d362) #179024: Consolidate repeated fixtures and assertions while retaining regression coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4e4f76f adds src/commands/status.command.ts:230 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4e4f76f1515c; files: src/commands/status.command.ts)
  • Jerome: Raw commit bc097bf adds src/cli/expected-cli-error.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bc097bf6404f; files: src/cli/expected-cli-error.ts)

PR surface

Source +12, Tests +59, Other +5. Total +76 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 13 1 +12
Tests 1 60 1 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 0 +5
Total 3 78 2 +76

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A bounded CLI diagnostic bug hides the useful reason for an unreachable Gateway without changing runtime availability.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-11-09T15:58:20.590Z sha 8714862 :: needs real behavior proof before merge. :: [P2] Explain isolation for the new audit mock | [P2] Retain a recovery action beside the health reason
  • reviewed 2026-11-09T23:23:16.828Z sha fd44f20 :: needs changes before merge. :: [P2] Use a recovery hint that applies to the selected Gateway
  • reviewed 2026-11-10T00:00:39.510Z sha 88bf2b9 :: needs changes before merge. :: [P2] Use a recovery hint that also works without an installed service
  • reviewed 2026-11-10T00:18:25.949Z sha 345ca40 :: needs changes before merge. :: [P2] Use recovery guidance that respects external supervision
  • reviewed 2026-11-10T00:42:09.268Z sha 3b51b66 :: needs maintainer review before merge. :: none

Reviewed November 10, 2026, 6:42 AM ET / 11:42 UTC (Revision 6).

ClawSweeper: with no reachable Gateway the expected error's human output must
carry a concrete recovery step, not only the health reason. Keep the machine
output stable (the probe error alone) while the human output adds the managed
gateway start command. Also annotate the new audit mock's isolation.
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed all three findings:

  1. Real behavior proof now through the supported shipped launcher (built dist, node openclaw.mjs, Node 24, isolated HOME): base prints "The CLI command failed." + exit 1; head prints "Gateway is unreachable" + recovery step + exit 1. JSON machine output unchanged.
  2. The new audit mock now carries a mock-isolation annotation explaining why the real security audit stays outside this fixture.
  3. Human output now retains a concrete recovery step ("Run openclaw gateway start to start a managed gateway.") beside the health reason; machine output keeps the stable probe error.

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Nov 9, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Re-review the current head (fd44f20): the recovery hint and audit mock annotation are now committed, and the body's real behavior proof runs through the built shipped launcher (node openclaw.mjs).

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
The gateway start instruction only applies to a stopped local managed
service; for a remote gateway target it cannot recover the remote host.
Keep the probe reason for both cases and condition the start hint on
gateway.mode=local, using a target-neutral check for remote targets.
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the P2 finding: the recovery hint is now conditional on gateway.mode. For a local gateway it keeps Run openclaw gateway start to start a managed gateway.; for a remote target it uses the target-neutral Check that the configured remote gateway is running and reachable., so the hint never starts an unrelated local service. Two new regression cases assert the local and remote branches (the remote case is red against an unconditional start hint). Red/green: 8 passed + 1 remote-hint test red on the unconditional base; 9/9 green on the conditional head. Test-line budget updated to 72 (ratchet green).

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 9, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the remaining local-service finding: the recovery hint now checks the service snapshot. For a local gateway with an installed managed service it recommends openclaw gateway start; without an installed service it recommends openclaw gateway install (start refuses and prints install hints in that state); a remote target keeps the target-neutral check. New regression recommends gateway install when no local service is installed is red against an unconditional start hint and green with the install-state conditional. Red/green: 9 passed + install case red on the unconditional base; 9/9 green on the conditional head. Also dropped the redundant health-reason-only regression per the review note. Test-line budget updated to 75 (ratchet green).

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
start/install can be refused by the service owner (for example under an
external supervisor), so selecting a lifecycle command from the gateway
mode or installation snapshot is not reliable. The recovery hint now
recommends the diagnostic `openclaw gateway status --deep` for both
local and remote targets, which is never refused and needs no
eligibility policy.

Consolidates the recovery-hint regression into a local/remote pair and
updates the test-line allocation to match.
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the external-supervision finding: the recovery hint no longer derives a lifecycle command from the gateway mode or installation snapshot. start/install can be refused by the service owner (external supervisor, no installed service), so the hint now recommends the diagnostic openclaw gateway status --deep for both local and remote targets — a command the service owner never refuses and that needs no eligibility policy. The regression now covers a local and a remote unreachable target, both red against the bare-Error base and green on the head (8/8). Test-line budget updated to 61 (ratchet green).

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
The mock-exports ratchet matches a `// mock-isolation:` annotation only
when it is the line immediately above the mock call; the previous
multi-line comment did not match and failed the CI ratchet.
The CI ratchet computes a 59-line net growth against its prepared base,
so the allocation must match instead of the local-main figure.
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 10, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The latest head (015da63) only adjusts the test-line allocation file to match the CI ratchet base plus a single-line formatting of the audit mock-isolation annotation — no production behavior change from the last reviewed head (3b51b66, clean review). CI is fully green on this head. Re-review the current head so the durable verdict and readiness labels track it.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 10, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this along with the other open PRs that apply the same change one call site at a time. This series adds diagnostics, console output or terminal sanitization at each call site separately; terminal sanitization is a security-policy decision, and new diagnostic output is a product decision. Please open one issue (or one PR at the shared owner) that covers the whole pattern, with a reproduction of real user-visible harm, instead of separate per-site PRs. Further per-site variants of this pattern will be closed.

@obviyus obviyus closed this Nov 16, 2026
@wangmiao0668000666
wangmiao0668000666 deleted the fix/status-deep-health-error branch November 17, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants