Repository navigation
fix(cli): show why a command failed when the config cannot be read - #196816
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe CLI displays configuration read failures without sending users back to Doctor. Example: Run openclaw status with {"$include":"missing.json"} and no missing.json file.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a distinct current-main diagnostic gap with a focused change; no actionable defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCLI startup reads configuration before selecting storage; tagged read errors reach the shared root failure renderer, which produces redacted stderr diagnostics. flowchart LR
A[CLI command] --> B[Configuration snapshot]
B --> C[Engine selection]
C --> D[Tagged read error]
D --> E[Root failure renderer]
E --> F[Redacted stderr]
Technical reviewBest possible solution: Merge the focused shared-renderer repair once the existing required checks pass. Do we have a high-confidence way to reproduce the issue? The source traces a missing include through CONFIG_READ_FAILED into the generic main-branch renderer, and supplied built-CLI before/after output confirms the failure; no target code was executed during this review. Is this the best way to solve the issue? The existing root renderer owns diagnostic visibility, so recognizing the established error code there is the smallest complete fix and avoids duplicate printing at throw sites. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c301da9dca8d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests -1, Docs +1. Total +4 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource stale. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 10, 2026, 2:58 PM ET / 19:58 UTC (Revision 2). |
|
Proof at 455f041 (merged current main), built CLI on node:24.22.1 in a secretless Docker container, config
Also folded the new test case into one row so test lines are net -1. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 9d5de42. Thanks @masatohoshino. Unreadable configs now show the real reason. |
…penclaw#196816) fix(cli): show why a command failed when the config cannot be read When the config file could not be read, for example because an included file is missing, commands such as openclaw status printed only "The CLI command failed." and pointed to openclaw doctor, which failed the same way. For this case the CLI now prints the existing config-read reason from createConfigReadError and drops the Doctor hint. Other unexpected errors keep the generic line and the hint, and no wording is new. Evidence: the built CLI on node:24.22.1 in Docker with a config containing an include of a missing file. On main, status and doctor --non-interactive printed only the generic failure line and the Doctor hint, exit 1. With this change both print "Reason: Config could not be read at .../openclaw.json: - <root>: Failed to read include file: ./missing.json (resolved: ...)" with no Doctor hint, exit 1. status --json gives the same JSON on both, an unrelated failure still prints the generic line and the hint on both, and a valid config behaves the same on both. Details: openclaw#196816 (comment). Closes openclaw#196815. Thanks @masatohoshino. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #196815
What Problem This Solves
Fixes: when the config file cannot be read, commands such as
openclaw statussay only "The CLI command failed." and send the user toopenclaw doctor, which fails the same way, instead of naming the file that could not be read.User Impact
User impact: a user with an unreadable config now sees why the command failed:
The circular "run
openclaw doctor" line is no longer printed for this failure, since Doctor cannot read the file either.Why This Change Was Made
Before a command runs, the CLI reads the config to choose the storage engine. When that read fails, the error is thrown without being printed, and the root failure output only showed a reason for invalid configs and a few named commands, so the read error was dropped. The root failure output now treats a config read failure the way it already treats state-database refusals: it prints the title and the redacted reason, without the Doctor line. #158671 separated read failures from invalid configs and removed Doctor advice for them on the paths it touched; this is the root path it did not reach.
Behavior to know:
CONFIG_READ_FAILEDchange. Invalid configs, state-database refusals and every other failure keep their current output.OPENCLAW_DEBUG=1.--jsonfailure output is unchanged.openclaw config validate, setup and bareopenclaware not changed here; fix(cli): diagnose unreadable configuration in validation and setup #166573 (open) owns their read-failure wording, and this change does not touch its files.Docs:
docs/cli/index.mdgains one line under failure output.Evidence
Tested at c8eae97 (baseline 080ed32).
Before/After at the CLI boundary: a before/after harness built both sides from source and ran the same steps in fresh isolated homes. Each side wrote a config whose only content is
{"$include":"missing.json"}and then ranopenclaw status,openclaw agents listandopenclaw doctor --non-interactive. All three exit 1 on both sides; stdout is identical. Stderr, with the per-side home path normalized:The same difference appears for all three commands. The expectation "stderr names the read error" is not met before and is met after for each of them.
Regression test: a
createConfigReadErrorrow in the existing "keeps actionable refusal details without leaking diagnostics" table ofsrc/cli/failure-output.test.ts. It expects the read error as the reason, no Doctor line, and no leaked token, nested cause or stack. It fails on the baseline (the reason line is missing) and passes at the head; the other 20 tests in the file pass on both.Checks at the head:
pnpm test src/cli/failure-output.test.ts --maxWorkers=1: 21 passed.test/tsconfig/tsconfig.core.test.config-cli.json: clean.scripts/check-test-lines-ratchet.mts:Test lines OK.Local review: autoreview (Codex gpt-6.1-sol, medium), base 080ed32 to head c8eae97, priority P0–P1: scoped-clean, no remaining findings.
Simplification pass: the smallest complete fix is one branch at the existing root failure printer, which already decides which reasons are shown. Fixing it at the throw site would print the error twice. Against the merge base, production code is +5/−1 (a four-line branch and the import), test code +6/−1 (one table row and the import), and docs +1. Nothing was removed because no duplicate path exists.
src/cli/failure-output.test.tsit.eachtable;pnpm test src/cli/failure-output.test.ts --maxWorkers=1: 57.5 s wall locally, almost all of it worker startup; the new row adds no measurable CI secondsNot covered:
CONFIG_READ_FAILEDerror, but only the missing include was run end to end.openclaw models listand other commands that select the storage engine take the same path but were not run end to end.config validate, setup, bareopenclaw) keep their own output; see fix(cli): diagnose unreadable configuration in validation and setup #166573.