fix(cli): emit JSON for gateway transport failures#79233
fix(cli): emit JSON for gateway transport failures#79233TurboTheTurtle wants to merge 2 commits into
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. source-level. Current main awaits gateway RPC calls before stdout JSON writes in health, gateway health, and devices list, and #79108 provides concrete unavailable-gateway commands for the failing paths. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Rebase or repair this PR onto current main, port the devices-list handling into src/cli/devices-cli.runtime.ts, then land one shared typed serializer for the linked issue. Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main awaits gateway RPC calls before stdout JSON writes in health, gateway health, and devices list, and #79108 provides concrete unavailable-gateway commands for the failing paths. Is this the best way to solve the issue? Yes in direction, but not in the current branch state. A shared serializer for typed GatewayTransportError failures is narrow and maintainable, but the devices-list catch must move to the current runtime split before merge. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against ea16a5e9e10c. |
|
Agreed. I’ll add an active-version changelog bullet and update the PR body with after-fix output from a real unavailable-gateway run for the affected JSON commands. The goal is to show stdout contains |
f4c949c to
47982b1
Compare
|
Resolved the GitHub merge conflict by rebasing this branch onto current Validation: |
47982b1 to
66e9741
Compare
|
Rebased this once more after Validation: |
66e9741 to
6e11902
Compare
6e11902 to
877bff0
Compare
877bff0 to
d3c63ef
Compare
d3c63ef to
f5d4ad4
Compare
|
Resolved the current merge conflict by rebasing Conflict resolved:
Validation on rebased head:
Author check before push: If this PR is squash-merged or reworked, please preserve author attribution or include: |
|
Thanks for the focused fix. I landed a repaired equivalent on main in #82690 / e06782d, with contributor credit preserved. What changed from this PR before landing:
Proof: focused Vitest passed after final rebase (8 files / 348 tests), and Blacksmith Testbox through Crabbox passed |
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Fix logs.tail credential-header redaction and JSON-mode gateway transport errors.\n\nFixes openclaw#66832.\nFixes openclaw#79108.\nSupersedes openclaw#67041.\nSupersedes openclaw#79233.\n\nCo-authored-by: Mil Wang <mingjwan@microsoft.com>\nCo-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Summary
--jsoncould exit on transport close/timeout without writing JSON to stdout.GatewayTransportErrorJSON serializer and used it for JSON-modehealth,gateway health, anddevices listtransport failures.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
{ "ok": false, "error": ..., "gateway": ... }payload when the gateway transport closes or times out before returning an RPC result.ws://127.0.0.1:9with a redacted proof token.OPENCLAW_GATEWAY_URL=ws://127.0.0.1:9 OPENCLAW_GATEWAY_TOKEN=proof-token pnpm openclaw health --json --timeout 500pnpm openclaw gateway health --url ws://127.0.0.1:9 --token proof-token --json --timeout 500pnpm openclaw devices list --url ws://127.0.0.1:9 --token proof-token --json --timeout 500ELIFECYCLE Command failed with exit code 1).health --jsonredacted output:{ "ok": false, "error": { "type": "gateway_transport_error", "kind": "closed", "message": "gateway closed (1006 abnormal closure (no close frame)): no close reason", "code": 1006, "reason": "no close reason" }, "gateway": { "url": "ws://127.0.0.1:9", "urlSource": "env OPENCLAW_GATEWAY_URL" } }gateway health --jsonanddevices list --jsonproduced the same structured error shape with:{ "gateway": { "url": "ws://127.0.0.1:9", "urlSource": "cli --url" } }Root Cause (if applicable)
callGatewayalready produced typedGatewayTransportErrorinstances, but affected JSON commands awaited the gateway RPC before reaching their success-only JSON output branch. The typed transport error escaped to the generic CLI error path, which wrote human-readable stderr and exited without stdout JSON.Regression Test Plan (if applicable)
src/gateway/call.test.tssrc/commands/health.test.tssrc/cli/gateway-cli.coverage.test.tssrc/cli/devices-cli.test.tsUser-visible / Behavior Changes
When
--jsonis requested, transport-level gateway close/timeout failures now produce stdout JSON before exiting with code 1.Diagram (if applicable)
N/A
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
Steps
Expected
ok: false, transportkind, message/code/timeout details, and gateway target metadata.Actual
health --json,gateway health --json, anddevices list --json.Evidence
Human Verification (required)
health --json,gateway health --json,devices list --json, and status/health wrapper option forwarding.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
--jsonis explicitly requested, matching the documented machine-readable contract.Changelog
Additional Validation Note
pnpm exec vitest run src/gateway/call.test.ts src/commands/health.test.ts src/cli/gateway-cli.coverage.test.ts src/cli/devices-cli.test.ts --reporter=dot: passed (Test Files 6 passed,Tests 288 passed).pnpm exec vitest run src/cli/program/register.status-health-sessions.test.ts --reporter=dot: passed (Test Files 1 passed,Tests 21 passed).pnpm tsgo:core: passed.pnpm tsgo:core:test: passed.pnpm exec oxfmt --check --threads=1 src/gateway/call.ts src/gateway/call.test.ts src/commands/health.ts src/commands/health.test.ts src/cli/gateway-cli/call.ts src/cli/gateway-cli/register.ts src/cli/gateway-cli.coverage.test.ts src/cli/devices-cli.ts src/cli/devices-cli.test.ts CHANGELOG.md: passed.git diff --check: passed.