Skip to content

fix: preserve Gateway error reasons in text logs - #130645

Merged
steipete merged 1 commit into
mainfrom
codex/qa32-logs-errors
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa32-logs-errors

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130616

What Problem This Solves

Fixes an issue where operators using text-mode openclaw logs saw only “Gateway not reachable” when a reachable Gateway rejected logs.tail. The actual server reason was discarded, making an RPC rejection look like a connection failure. JSON already retained the reason.

Why This Change Was Made

The terminal-error owner already formats and redacts the authoritative error. Text output now sends that prepared string through its existing safe stderr writer instead of the generic reachability message. No new formatter, fallback, or control-flow branch is introduced. JSON shape and wording, selected-target diagnostics, auth, retries/recovery, broken-pipe handling, and exit behavior remain unchanged.

User Impact

Human-readable logs failures now show the actionable error alongside the selected Gateway details and doctor hint. The same terminal projection covers exhausted follow retries and non-recoverable failures. URL credentials stay redacted; stdout stays empty on the tested terminal rejection. The CLI reference documents the text behavior without changing the JSON contract.

Evidence

Before the repair, a real built CLI connected to a credential-free loopback WebSocket fixture and received INVALID_REQUEST: logs unavailable for this client. Both text and JSON reached connect and logs.tail, exited 1, and emitted no stdout. Only JSON retained the reason; the text assertion failed. The new focused redaction/reason assertion also failed on unchanged production.

After the fix, the same rebuilt-CLI process probe passed: text stderr begins logs unavailable for this client, followed by selected connection details and the doctor hint. JSON output remains unchanged. Temporary HOME/config/state and an ephemeral loopback port were used; no operator Gateway or external service was accessed.

175 focused tests passed across logs, recovery, JSON, auth forwarding, error formatting, URL redaction, and safe-stream writing:

node scripts/run-vitest.mjs src/cli/logs-cli.test.ts src/cli/logs-cli.runtime.test.ts src/cli/gateway-port-option.test.ts src/cli/gateway-rpc.runtime.test.ts src/cli/json-output-mode.test.ts src/infra/errors.test.ts src/logging/log-tail-redaction.test.ts packages/net-policy/src/redact-sensitive-url.test.ts packages/terminal-core/src/stream-writer.test.ts

The worker sandbox denied loopback socket creation before assertions. The coordinator reran the original owner/port order through the normal local test path: 49 tests passed, including all nine socket-boundary cases. This overlaps the 175-test run; it is not an extra 49 unique tests.

node scripts/run-vitest.mjs src/cli/logs-cli.test.ts src/cli/logs-cli.port.test.ts
node scripts/check-changed.mjs -- src/cli/logs-cli.ts src/cli/logs-cli.test.ts src/cli/logs-cli.port.test.ts docs/cli/logs.md
node --import tsx scripts/build-all.mts
git diff --check

All passed, along with targeted formatting and docs review. Full build completed in 5m 7.3s; existing dependency direct-eval warnings were nonfatal. Fresh independent P1 autoreview found no actionable findings (correct, confidence 0.96).

Exact-head CI 33040754720 is green on 4d129de6de72aa266da955775ed555ed30e4ad4f. Native review artifacts validate at READY FOR /prepare-pr; current-main comparison found no changes in the affected owner/tests/docs. The earlier draft-only CI was skipped and is not counted as proof. The latest ClawSweeper comment remains a review-started placeholder, with no published verdict/rank-up list; it is not counted as completed review.

Production +1/-1, net zero; tests +21/-8; docs +2/-0. Tests extend existing error/follow and WebSocket fixtures without a new production seam. No schema, protocol, configuration, dependency, or persistence change. AI-assisted repair; release-note context is the restored diagnostic behavior above.

Documentation: https://docs.openclaw.ai/cli/logs.

Print the existing formatted and redacted RPC error instead of a generic reachability claim. Preserve JSON output, selected-target details, fallback/recovery, auth and exit behavior. Verified with real loopback rejection and built CLI before/after proof. Closes #130616.
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: XS maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 04:52
@steipete steipete self-assigned this Aug 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready at 4d129de6de72aa266da955775ed555ed30e4ad4f: CI33040754720 is green; native artifacts validate at READY FOR /prepare-pr, no findings. This resumes the original interrupted publication, without a duplicate PR or rebase.

The root cause is the text terminal-error projection discarding its already-formatted/redacted reason. One argument replacement restores the reason through the existing safe stderr writer; JSON, auth, selected target, retries/fallback and exit handling remain unchanged. Production+1/-1; tests+21/-8; docs+2.

Before: real built CLI accepted connect, received the logs.tail rejection, and hid its reason only in text mode; the expected text assertion failed. After: the same isolated loopback process probe retains logs unavailable for this client plus connection/doctor guidance; both modes exit1 with empty stdout, JSON unchanged.

Completed proof:175 focused tests; coordinator rerun49 owner/port tests including all9 real socket cases (overlaps175); full build; changed gates; formatting/docs/diff checks. The worker's socket tests were blocked before assertions by its sandbox; the coordinator's successful socket and process runs close that gap. Exact commands:

node scripts/run-vitest.mjs src/cli/logs-cli.test.ts src/cli/logs-cli.port.test.ts
node scripts/check-changed.mjs -- src/cli/logs-cli.ts src/cli/logs-cli.test.ts src/cli/logs-cli.port.test.ts docs/cli/logs.md
node --import tsx scripts/build-all.mts
git diff --check

Independent P1 review clean0.96. Current main has no affected owner/test/docs drift. The latest ClawSweeper comment is still a started placeholder, not a verdict; no rank-up list is published. No local proof gap remains for this CLI diagnostic change. Proceeding through native hosted-CI prepare/merge.

@steipete
steipete merged commit 036e635 into main Aug 27, 2026
212 checks passed
@steipete
steipete deleted the codex/qa32-logs-errors branch August 27, 2026 05:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 27, 2026
…-retirement-v13

* origin/main: (243 commits)
  fix: preserve Gateway error reasons in text logs (#130645)
  refactor(video): deduplicate generation contracts (#130635)
  fix(agents): preserve direct-message sender identity (#124548)
  fix(agents): preserve silent reply after settled tools (#130675)
  fix(talk): preserve replacement speech when an old utterance is canceled (#130687)
  fix(browser): preserve literal names and formatter-owned snapshot refs (#130599)
  fix(auth): reset only the profile replaced by a successful login (#124014)
  fix: bind session creation to admitted Gateway (#130686)
  refactor(qa-lab): reuse model reference splitter (#130317)
  docs(gateway): clarify independent HTTP endpoint switches (#130690)
  fix(ui): Control UI smooth scrolling ignores the reduced-motion preference (#130428)
  refactor(lmstudio): remove unreachable catalog merge (#130689)
  fix(crabbox): restore cloud machine CPU and RAM (#130684)
  fix(secrets): compare proxy bearer tokens directly (#127054)
  fix(matrix): show recovery key availability in text status (#128051)
  fix(ios): restore approval settings navigation and remove duplicate shell state (#130651)
  refactor(agents): use fixed tool-loop defaults directly (#130681)
  refactor(qa-lab): share process tree metric reader (#130419)
  refactor(models): simplify prepared owner access (#130683)
  fix(parallels): main install and update smoke cannot complete (#130658)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
Print the existing formatted and redacted RPC error instead of a generic reachability claim. Preserve JSON output, selected-target details, fallback/recovery, auth and exit behavior. Verified with real loopback rejection and built CLI before/after proof. Closes openclaw#130616.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Text logs discard the Gateway RPC failure reason

1 participant