Skip to content

fix(cli): render Gateway health JSON failures - #129106

Merged
steipete merged 1 commit into
mainfrom
autoqa30-gateway-health-json
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
autoqa30-gateway-health-json

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Route-first gateway health --port ... --json returned empty stdout when local config resolution failed before RPC setup, while forced Commander correctly emitted a canonical JSON failure.

Fixes #129105.

Why This Change Was Made

The health fast route now rethrows failures that occur before RPC options are resolved, allowing the existing root renderer to own JSON/human output and terminal finalization. The post-RPC specialized Gateway diagnostic/formatter path remains unchanged.

Production delta: +1/-4, net -3 lines. Tests: +62/-17, net +45 lines.

User Impact

Routed Gateway health failures now produce parseable JSON consistent with Commander. Target selection, read-only RPC behavior, specialized Gateway payloads, and human output remain unchanged.

Evidence

  • Pre-fix routed JSON regression reproduced empty stdout; forced Commander was already correct.
  • Focused owner/sibling proof: 61 tests passed.
  • Built-process proof: 13 Gateway query/health cases passed across routed JSON, human, Commander, dual TTY, no-connection/no-state, and specialized payload paths.
  • CLI startup build and complete changed-file gates passed.
  • Fresh final P1 autoreview: no actionable findings.
  • git diff --check: passed.

Malformed shared configuration behavior remains tracked in #128606.

@clawsweeper

clawsweeper Bot commented Aug 25, 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 25, 2026 07:26
@steipete steipete self-assigned this Aug 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete steipete closed this Aug 25, 2026
@steipete steipete reopened this Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 3:36 AM ET / 07:36 UTC.

ClawSweeper review

What this changes

The PR routes Gateway health pre-RPC configuration failures to the root CLI renderer so JSON callers receive the canonical error document.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this focused fix open. Current main still locally handles the pre-RPC configuration failure with stderr and exit only, while the PR correctly rethrows it to the established root JSON renderer without changing the specialized post-RPC Gateway error path.

Priority: P1
Reviewed head: 69433a61ad92adda26a40eef247c20af16dc79f1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused owner-boundary repair with relevant unit and built-process regression coverage; exact-head checks remain the merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports built-process coverage of the changed CLI behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports built-process coverage of the changed CLI behavior.
Evidence reviewed 5 items Current-main failure path: Current main still writes the pre-RPC error to stderr and exits locally, so it cannot emit the root canonical JSON failure envelope.
Canonical renderer: The executable entrypoint converts thrown errors in JSON mode through formatCliJsonFailure before writing the terminal result.
Owner-boundary fix: The PR rethrows only when RPC options were not resolved; errors after RPC setup continue into the existing Gateway diagnostic and structured-error branch.
Findings None None.
Security None None.

Live Verification

Command: pnpm test test/cli-json-stdout.e2e.test.ts

Result: FAIL (partial) — step 2 expect_output cli json stdout contract: expected terminal output was not visible within 30 seconds: "cli json stdout contract"

pnpm test test/cli-json-stdout.e2e.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129106-V9GzDw/target$ pnpm test test/cli-json-stdout.e2e.test.ts
$ node --import tsx scripts/test-projects.mts test/cli-json-stdout.e2e.test.ts
[test] starting test/vitest/vitest.e2e.config.ts
pnpm test test/cli-json-stdout.e2e.test.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129106-V9GzDw/target

[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[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:deps (46%)
  - rolldown-plugin-dts:generate (22%)
  - rolldown-plugin-dts:fake-js (21%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

[tsdown-build] invocation 1/11 finished in 4.9s































Assertions:

  • FAIL expect_output: cli json stdout contract

How this fits together

Gateway health has a route-first JSON path that resolves local configuration before it performs a read-only Gateway RPC. Pre-RPC failures must reach the root CLI entrypoint for consistent JSON or human terminal output, while Gateway-specific RPC failures retain their specialized formatter.

flowchart LR
  A[Gateway health command] --> B[Route-first JSON dispatch]
  B --> C[Resolve local configuration]
  C -->|success| D[Read-only Gateway RPC]
  C -->|failure| E[Root CLI renderer]
  D --> F[Gateway-specific diagnostics]
  E --> G[JSON or human terminal output]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - The visible check set is cancelled/failing and GitHub reports the branch behind main; rerun the focused process proof and required exact-head checks on the final merge result before landing.
  • Complete next step (P2) - No mechanical repair remains; the protected maintainer-owned PR needs normal exact-head CI and merge-result validation.
Agent review details

Security

None.

PR surface

Source -3, Tests +45. Total +42 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 4 -3
Tests 2 62 17 +45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 63 21 +42

Review metrics

Metric Value Why it matters
Production versus test delta production +1/-4 (net -3); tests +62/-17 (net +45) The production change deletes a competing local failure renderer while the test growth covers the real built-CLI output contract.

Stored data model

Persistent data-model change detected: serialized state: test/cli-json-stdout.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the route-local rethrow after exact-head validation, preserving the root renderer as the sole owner of pre-RPC CLI failures and the Gateway formatter as owner of post-RPC failures.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the route-local rethrow after exact-head validation, preserving the root renderer as the sole owner of pre-RPC CLI failures and the Gateway formatter as owner of post-RPC failures.

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

Yes, source establishes the path: current main locally writes and exits before the root JSON renderer, and the added built-process test injects that same configuration-read failure.

Is this the best way to solve the issue?

Yes. Rethrowing only before RPC options exist uses the established root renderer and leaves the post-RPC Gateway-specific diagnostic contract intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8c5a12c112e6.

Labels

Label changes:

  • add P1: The existing route can silently produce empty stdout for a documented machine-readable CLI mode, breaking automation on a Gateway health workflow.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: The existing route can silently produce empty stdout for a documented machine-readable CLI mode, breaking automation on a Gateway health workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the implicated pre-RPC branch to Peter Steinberger, and the local history shows repeated Gateway health JSON and error-formatting work. (role: current path author and recent area contributor; confidence: high; commits: 8f0503657c0b, ba8bccb750c0, d81465f779e4; files: src/cli/gateway-cli/health-route.ts, src/cli/gateway-cli/register.ts, src/cli/run-main.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rerun the focused built-process CLI proof and required checks against the final merge result.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head 69433a61ad92adda26a40eef247c20af16dc79f1:

  • Root cause: route-first Gateway health handled pre-RPC local config resolution failures with stderr+exit, bypassing root JSON rendering; Commander already propagated them.
  • Canonical repair: failures before RPC resolution are rethrown; post-RPC reachable-auth and specialized Gateway handling remain unchanged.
  • Production: +1/-4, net -3 lines. Tests: +62/-17.
  • Focused owner/sibling proof: 61 tests passed.
  • Built-process proof: 13 routed JSON/human/Commander/dual-TTY/no-connection/no-state and specialized Gateway cases passed.
  • CLI startup build and complete changed-file gates passed.
  • Final P1 autoreview: no actionable findings, correctness 0.90.
  • Exact-head CI run: https://github.com/openclaw/openclaw/actions/runs/32822933676 — relevant gate passed; watcher completed green after temporary GraphQL quota retries.
  • Native review artifacts: validated with zero findings and READY FOR /prepare-pr.

Shared malformed-config divergence remains tracked in #128606.

@steipete
steipete merged commit 1901dda into main Aug 25, 2026
258 of 308 checks passed
@steipete
steipete deleted the autoqa30-gateway-health-json branch August 25, 2026 08:04
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Route-first Gateway health JSON failure emits empty stdout

1 participant