Skip to content

fix(cli): keep Gateway auth failures parseable in JSON - #116597

Merged
steipete merged 3 commits into
mainfrom
codex/autoqa-health-json-171-20260730
Jul 31, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/autoqa-health-json-171-20260730

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Gateway-backed CLI commands requested in JSON mode could fail before transport startup with empty stdout or prose stderr when credentials were missing or unavailable. Automation calling health, routed gateway health, or gateway call could not reliably parse the failure.

Why This Change Was Made

A shared Gateway auth-error formatter now maps only the recognized pre-transport credential failures into the existing gateway_credentials_required JSON envelope. All three CLI entry points apply it before request/transport formatters, while reachable-Gateway diagnostics and authenticated transport failures retain their existing distinct envelopes.

No authentication policy, credential lookup, Gateway protocol, config, or human-readable command behavior changes.

User Impact

JSON callers always receive one parseable failure object and a nonzero exit for missing Gateway credentials. Authenticated connection failures still report gateway_transport_error, so automation can distinguish setup from reachability.

Evidence

  • Before-fix real-process reproduction: missing-auth JSON invocations exited 1 with empty stdout or prose stderr across top-level health, routed Gateway health, and Gateway call.
  • Focused Testbox proof passed 191 CLI-process, CLI-route, health-command, and Gateway-call tests, including authenticated-unreachable preservation (run 30589260750).
  • The same Testbox completed the full production build successfully.
  • Source-blind built-CLI validation on Testbox tbx_01kytm93xjqqw9ncpczm3qkh0r passed all 5 contract clauses: three credential-failure entry points, explicit-URL auth failure, and authenticated unreachable transport failure. Every case exited 1, emitted zero stderr bytes, and parsed the complete stdout JSON as the expected error type.
  • Final rebased exact-head changed gate and Codex autoreview are recorded in the branch/PR checks.
  • git diff --check is clean.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations size: M maintainer Maintainer-authored PR labels Jul 31, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 8:35 PM ET / July 31, 2026, 00:35 UTC.

ClawSweeper review

What this changes

The branch adds a shared formatter for pre-transport Gateway credential errors and applies it to JSON-mode health, routed Gateway health, and Gateway call commands so automation receives a parseable gateway_credentials_required result.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this PR open for protected-label maintainer handling. The focused patch appears to preserve the existing Gateway error taxonomy while making three JSON CLI entry points emit the established credential envelope; its reported built-CLI proof is strong, but the exact head still has required checks in progress and the maintainer label requires an explicit landing decision.

Priority: P2
Reviewed head: 75ed8a5157c75a584153a0abf4890724f76138a2
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-tested contract repair with credible built-CLI behavior proof; the remaining gate is protected-label maintainer approval and completion of exact-head checks.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides after-fix source-blind built-CLI evidence across the three changed command paths plus explicit-URL and authenticated-unreachable controls; redact any private paths or endpoints if additional logs are posted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides after-fix source-blind built-CLI evidence across the three changed command paths plus explicit-URL and authenticated-unreachable controls; redact any private paths or endpoints if additional logs are posted.
Evidence reviewed 5 items Shared recognized-error boundary: The branch adds formatGatewayAuthErrorJson, which returns the existing gateway_credentials_required envelope only for configured-credential, explicit-URL credential, or unavailable SecretRef failures; unrelated errors still return null.
All stated JSON entry points use the formatter first: The routed Gateway health handler, generic Gateway command wrapper, and top-level health command all try the auth formatter before their existing request or transport formatters, preserving distinct transport handling for authenticated connection failures.
Regression coverage preserves the boundary: Focused tests cover recognized credential failures, unrelated errors, routed health, Gateway call, and top-level health behavior, including the authenticated-unreachable transport distinction described in the PR.
Findings None None.
Security None None.

How this fits together

Gateway-backed CLI commands resolve credentials before opening a WebSocket transport, then format failures for either people or JSON automation. This change intercepts recognized credential failures at that pre-transport boundary and returns the existing structured JSON error instead of falling through to empty or prose-only output.

flowchart LR
  A[CLI JSON command] --> B[Gateway credential resolution]
  B --> C{Credentials available?}
  C -- Yes --> D[Gateway request and transport]
  C -- No --> E[Shared auth error formatter]
  E --> F[Parseable credentials-required JSON]
  D --> G[Existing success or transport result]
Loading

Decision needed

Question Recommendation
After the exact-head checks complete, should this PR be merged as the canonical JSON error-contract fix for pre-transport Gateway credential failures? Merge after checks complete: Confirm the existing gateway_credentials_required envelope is the intended contract and land once required exact-head checks pass.

Why: The patch is narrowly scoped and evidence-backed, but the protected maintainer label requires an explicit human landing decision and confirmation of the public CLI error contract.

Before merge

  • Resolve merge risk (P1) - The PR is cleanly mergeable but behind main; refresh the exact merge result and let the in-progress required checks finish before landing.
  • Resolve merge risk (P1) - The maintainer label is a protected signal, so a human should explicitly confirm that the updated JSON error behavior is the intended CLI contract.
  • Complete next step (P2) - No mechanical repair is identified; the remaining action is protected-label maintainer confirmation after exact-head checks complete.
Agent review details

Security

None.

PR surface

Source +37, Tests +286. Total +323 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 46 9 +37
Tests 5 287 1 +286
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 333 10 +323

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow shared formatter after exact-head checks complete and a maintainer confirms that gateway_credentials_required remains the intended machine-readable contract for all three pre-transport credential-failure paths.
  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 narrow shared formatter after exact-head checks complete and a maintainer confirms that gateway_credentials_required remains the intended machine-readable contract for all three pre-transport credential-failure paths.

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

Yes, source and the PR’s reported built-CLI evidence define a concrete path: invoke JSON-mode Gateway health or call commands with missing, explicit-URL, or unavailable SecretRef credentials and inspect stdout, stderr, exit code, and error type. This review did not independently rerun that process.

Is this the best way to solve the issue?

Yes. A single shared formatter at the credential/transport boundary, called before existing request and transport formatters, is narrower and less drift-prone than separate error serialization logic in each CLI entry point.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded automation-facing CLI failure mode: JSON callers cannot reliably parse missing-Gateway-credential failures.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix source-blind built-CLI evidence across the three changed command paths plus explicit-URL and authenticated-unreachable controls; redact any private paths or endpoints if additional logs are posted.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix source-blind built-CLI evidence across the three changed command paths plus explicit-URL and authenticated-unreachable controls; redact any private paths or endpoints if additional logs are posted.

Label justifications:

  • P2: This repairs a bounded automation-facing CLI failure mode: JSON callers cannot reliably parse missing-Gateway-credential failures.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix source-blind built-CLI evidence across the three changed command paths plus explicit-URL and authenticated-unreachable controls; redact any private paths or endpoints if additional logs are posted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix source-blind built-CLI evidence across the three changed command paths plus explicit-URL and authenticated-unreachable controls; redact any private paths or endpoints if additional logs are posted.

Evidence

What I checked:

  • Shared recognized-error boundary: The branch adds formatGatewayAuthErrorJson, which returns the existing gateway_credentials_required envelope only for configured-credential, explicit-URL credential, or unavailable SecretRef failures; unrelated errors still return null. (src/gateway/call.ts:308, 75ed8a5157c7)
  • All stated JSON entry points use the formatter first: The routed Gateway health handler, generic Gateway command wrapper, and top-level health command all try the auth formatter before their existing request or transport formatters, preserving distinct transport handling for authenticated connection failures. (src/cli/gateway-cli/health-route.ts:89, 75ed8a5157c7)
  • Regression coverage preserves the boundary: Focused tests cover recognized credential failures, unrelated errors, routed health, Gateway call, and top-level health behavior, including the authenticated-unreachable transport distinction described in the PR. (src/gateway/call.test.ts:1807, 75ed8a5157c7)
  • Reported real behavior proof: The PR body records source-blind built-CLI validation of five clauses on Testbox: three credential-failure paths, explicit-URL auth failure, and authenticated-unreachable transport failure, each with exit code 1, zero stderr bytes, and parseable stdout JSON. (75ed8a5157c7)
  • Protected maintainer handling: The supplied PR context includes the maintainer label and incomplete exact-head checks; repository policy keeps protected-label PRs open for explicit maintainer handling rather than automated cleanup.

Likely related people:

  • steipete: The supplied PR history attributes all three commits, including the focused formatter and process-proof work, to steipete; no independent current-main history extraction was available in this read-only review environment. (role: current change author and Gateway CLI contributor; confidence: medium; commits: c12a9eb0166e, ef15cde5ada7, 75ed8a5157c7; files: src/gateway/call.ts, src/commands/health.ts, src/cli/gateway-cli/health-route.ts)

Rank-up moves

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

  • Let the in-progress exact-head checks finish, then have a maintainer confirm the public JSON error-contract decision.

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
steipete merged commit d81465f into main Jul 31, 2026
130 of 137 checks passed
@steipete
steipete deleted the codex/autoqa-health-json-171-20260730 branch July 31, 2026 00:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 31, 2026
…e2e-integration-20260730

* origin/main:
  fix(plugins): keep registry sqlite root consistent (#116427)
  fix(cli): keep Gateway auth failures parseable in JSON (#116597)
  fix(trajectory): preserve prompts in oversized events (#116220)
  test(buzz): add live QA Lab channel lane (#116298)
  chore(i18n): refresh native locales (#116567)
  feat: add OpenClaw TUI prototype skill (#116583)
  fix(update): accept concrete versions selected by ranges (#116585)
vincentkoc added a commit that referenced this pull request Jul 31, 2026
…-supported-paths

* origin/main: (168 commits)
  fix(plugins): keep registry sqlite root consistent (#116427)
  fix(cli): keep Gateway auth failures parseable in JSON (#116597)
  fix(trajectory): preserve prompts in oversized events (#116220)
  test(buzz): add live QA Lab channel lane (#116298)
  chore(i18n): refresh native locales (#116567)
  feat: add OpenClaw TUI prototype skill (#116583)
  fix(update): accept concrete versions selected by ranges (#116585)
  fix(agents): preserve locked session model routes
  test(qa-lab): preserve Matrix fault proxy identity
  fix(ci): extend OpenAI live profile setup budget (#116580)
  fix: prevent configured models from stalling startup (#116553)
  fix(cli): close MCP listener after one-shot commands
  fix(auto-reply): keep explicit NO_REPLY silent (#116548)
  test(discord): cover deferred backpressure terminals
  fix(discord): cancel backpressured realtime playback
  test(discord): cover realtime output backpressure
  fix(codex): add remote WebSocket heartbeat and reconnect (#116135)
  fix(macos): wait for the current reconnect snapshot (#116550)
  fix(outbound): recognize current-source message-tool sends (#116560)
  fix(voice-call): type cancelled consult outcomes
  ...

# Conflicts:
#	extensions/google/setup-api.test.ts
#	ui/src/e2e/model-setup.e2e.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 31, 2026
* fix(cli): preserve gateway auth JSON errors

* docs(changelog): note Gateway JSON auth errors

* docs(changelog): defer Gateway JSON note to release
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 31, 2026
* origin/main:
  fix(plugins): keep registry sqlite root consistent (openclaw#116427)
  fix(cli): keep Gateway auth failures parseable in JSON (openclaw#116597)
  fix(trajectory): preserve prompts in oversized events (openclaw#116220)
  test(buzz): add live QA Lab channel lane (openclaw#116298)
  chore(i18n): refresh native locales (openclaw#116567)
  feat: add OpenClaw TUI prototype skill (openclaw#116583)
  fix(update): accept concrete versions selected by ranges (openclaw#116585)
  fix(agents): preserve locked session model routes
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
…-supported-paths

* origin/main: (168 commits)
  fix(plugins): keep registry sqlite root consistent (openclaw#116427)
  fix(cli): keep Gateway auth failures parseable in JSON (openclaw#116597)
  fix(trajectory): preserve prompts in oversized events (openclaw#116220)
  test(buzz): add live QA Lab channel lane (openclaw#116298)
  chore(i18n): refresh native locales (openclaw#116567)
  feat: add OpenClaw TUI prototype skill (openclaw#116583)
  fix(update): accept concrete versions selected by ranges (openclaw#116585)
  fix(agents): preserve locked session model routes
  test(qa-lab): preserve Matrix fault proxy identity
  fix(ci): extend OpenAI live profile setup budget (openclaw#116580)
  fix: prevent configured models from stalling startup (openclaw#116553)
  fix(cli): close MCP listener after one-shot commands
  fix(auto-reply): keep explicit NO_REPLY silent (openclaw#116548)
  test(discord): cover deferred backpressure terminals
  fix(discord): cancel backpressured realtime playback
  test(discord): cover realtime output backpressure
  fix(codex): add remote WebSocket heartbeat and reconnect (openclaw#116135)
  fix(macos): wait for the current reconnect snapshot (openclaw#116550)
  fix(outbound): recognize current-source message-tool sends (openclaw#116560)
  fix(voice-call): type cancelled consult outcomes
  ...

# Conflicts:
#	extensions/google/setup-api.test.ts
#	ui/src/e2e/model-setup.e2e.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant