Repository navigation
fix(cli): redact machine-readable error payloads - #124075
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
cd86410 to
b2e09c6
Compare
|
Codex review: found issues before merge. Reviewed August 15, 2026, 3:34 AM ET / 07:34 UTC. ClawSweeper reviewWhat this changesThis PR applies the canonical redacting error formatter to several CLI human and JSON error paths, adds boundary regressions, and repairs an unrelated Control UI lint failure. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the latest lint-only commit did not address the prior P1. Shared Gateway and Node lifecycle failures still serialize raw caught errors into JSON responses, so class names and credential-shaped text can remain exposed. Priority: P1 Review scores
Verification
How this fits togetherCLI service commands call shared Gateway and Node lifecycle code, which turns service-manager failures into terminal text or machine-readable JSON. The formatter must run before that shared lifecycle owner emits its response. flowchart LR
A[Gateway or Node command] --> B[Shared lifecycle owner]
B --> C[Caught service error]
C --> D{Error formatting}
D --> E[Terminal failure]
D --> F[JSON failure response]
F --> G[Operator automation]
Before merge
Findings
Agent review detailsSecurityNeeds attention: A shared daemon lifecycle path still bypasses the redacting formatter before emitting JSON. PR surfaceSource +23, Tests +102. Total +125 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Format every caught service error in the shared lifecycle and install-response owners, then add JSON regressions that reject both a named error and a synthetic bearer token. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: make a shared service operation reject with a named error containing a bearer token and invoke Gateway or Node lifecycle Is this the best way to solve the issue? No. Updating status commands is insufficient because Gateway and Node lifecycle commands share the untouched lifecycle-core and response owners; those caught errors must use the canonical formatter there. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9e911d560102. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
ddc8f69 to
27937f6
Compare
|
Merged via squash.
|
Related: #123929
What Problem This Solves
Fixes an issue where several CLI failures exposed internal JavaScript error class names, and where
--jsoncommands serialized caught errors without redaction. The affected paths included System, Directory, Gmail webhook setup, daemon status, and config dry-run output; credential-shaped text in a thrown error could reach machine-readable stdout unchanged.This is AI-assisted work, reviewed and validated against the affected command boundaries.
Why This Change Was Made
PR #123929 moved direct
error(String(err))calls to the canonical redacting formatter, but its sweep missed values wrapped bydanger(...)and values nested insidewriteJson({ error: ... }). This change routes those surviving CLI rendering paths throughformatErrorMessage, including the omittedwebhooks gmail runcatch, unsafe preformatted daemon status messages, and SecretRef resolution failures that feed config dry-run JSON.Redaction remains caller-owned.
writeJsonandwriteStdoutare generic, byte-preserving output primitives used for structured and intentionally literal payloads; centrally rewriting their output would risk changing unrelated machine contracts and would repeat work for already-safe payloads. Formatting only caught errors preserves unrelated JSON bytes and keeps the existingerrorkeys and exit codes unchanged.No new cross-file CLI result abstraction was added. The canonical formatter is already the shared abstraction, while the existing command-local wrappers retain ownership of JSON selection, colorization, and exit behavior.
User Impact
Operators now receive readable error messages without internal class-name prefixes. Machine consumers keep valid JSON and the same keys, while secret-shaped values in caught errors are redacted before they reach stdout. All affected commands preserve their prior exit codes, and human output keeps terminal colorization.
Evidence
Before, the live Directory repro produced:
The pre-fix boundary run failed 15 assertions across the three reported commands, including a Gmail JSON case that observed the full synthetic credential-shaped value: https://github.com/openclaw/openclaw/actions/runs/31870151321
After building the exact head with the
cliStartupbuild profile, the isolated macOS repro (OPENCLAW_STATE_DIRunder/private/tmp,OPENCLAW_SKIP_CHANNELS=1) produced valid JSON with exit 1:{ "error": "Multiple agents are configured, but this operation has no explicit owner. Select an agent explicitly; CLI callers can pass --agent <id>, channels can add a binding, and ambient services can set their agentId target." }Human mode produced the same message without the class name and exited 1.
Validation:
node scripts/run-vitest.mjsacross 10 affected CLI suites: 514 passed — https://github.com/openclaw/openclaw/actions/runs/31870344158node scripts/check-changed.mjs: clean typecheck, lint, formatting, dead-code, import-cycle, and policy guards — https://github.com/openclaw/openclaw/actions/runs/31870393655node --import tsx scripts/build-all.mts cliStartup: passed on macOSdanger(String(error))calls or directwriteJson/writeRuntimeJsonerror payloads built fromString(error)undersrc/cliProduction LOC: +51/-28 (net +23, primarily canonical formatter imports and explicit safe formatting at security boundaries) | Tests: +138/-36 (net +102)