Repository navigation
fix(cli): print immutable-config refusals without crash framing - #143140
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. Reviewed September 9, 2026, 10:26 AM ET / 14:26 UTC (Revision 2). ClawSweeper reviewWhat this changesThe CLI prints externally managed and Nix-managed configuration refusals as plain guidance instead of adding crash banners, stack hints, and Doctor advice. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main still misclassifies immutable-config refusals, and no actionable defect was found in the proposed correction. The supplied CLI observations support the intended output. Priority: P3 Review scores
Verification
How this fits togetherConfiguration write guards reject CLI operations when an external deployment owns the configuration. The shared CLI failure renderer turns those errors into terminal guidance or a JSON error response. flowchart TD
A[CLI mutation command] --> B[Configuration write guard]
B --> C[Immutable configuration refusal]
C --> D[Shared error classification]
D --> E[Plain terminal guidance]
D --> F[JSON error response]
E --> G[Failure exit status]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +11, Tests +9. Total +20 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep immutable-config enforcement intact and consistently render its existing deployment remedy through the shared CLI error path. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the path: plugin enable throws an immutable-config error that current main sends through generic crash formatting. The PR supplies matching runtime observations; this review did not execute the CLI. Is this the best way to solve the issue? Yes. Extending the existing expected-error classifier is a narrow repair that preserves producer guidance, write protection, and the shared JSON envelope without loading the configuration stack into the renderer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e7567735b316. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
With `OPENCLAW_CONFIG_READONLY=1` (or `OPENCLAW_NIX_MODE=1`) the config
write guard refuses mutations with a message that already names the
remedy. `config set` printed it plainly, but `plugins enable`,
`plugins uninstall`, `update` and every other writer let it reach the
root failure renderer, which framed the refusal as a crash:
[openclaw] The CLI command failed.
[openclaw] Reason: Config is externally managed ...
[openclaw] Debug: set OPENCLAW_DEBUG=1 to include the stack trace.
[openclaw] Try: openclaw doctor
Doctor cannot lift an externally managed config, and there is no stack
worth reading. Classify `ConfigReadOnlyError` and
`NixModeConfigMutationError` as expected CLI conditions in the shared
predicate, the same lean name-based classification the credential
preflight errors use, so every writer prints the guard message as-is
and `--json` keeps the canonical `cli_error` envelope.
46cd201 to
41e6da5
Compare
|
Merged via squash.
|
…er-ownership-20260909 * origin/main: (147 commits) fix(cli): reject blank account selectors before command startup (#143088) fix(update): repair young runs after recorded drivers exit (#143136) test(telegram): close model callback fixture connections (#143197) improve(test): reduce Telegram policy fixture startup overhead (#143192) test(ci): stabilize systemd manager shim timing (#143134) fix(test): retire chat preview Escape listeners during teardown (#143191) test(memory-wiki): share visibility test callbacks (#143181) fix(ci): accept native iOS keychain filenames (#142968) fix(ci): show publication observations in FRV status (#143171) fix(github): point the stuck-FAQ auto-response at a live anchor (#143194) docs: correct verified accuracy defects in CLI, tools, and automation pages (#143179) refactor(tests): remove duplicate Mistral cache-cost test (#143172) fix(doctor): complete canonical model-reference migration (#142284) fix(ci): reject stale and empty timing sample cohorts (#143182) fix(ui): remove first-reply confetti from chat (#143167) docs: split help/faq into 13 topic pages (#143150) refactor(docs): require caller-owned route indexes (#143164) fix(android): distinguish connection status from chat readiness (#143128) refactor: share agent-turn execution test defaults (#143166) fix(cli): print immutable-config refusals without crash framing (#143140) ...
…claw#143140) With `OPENCLAW_CONFIG_READONLY=1` (or `OPENCLAW_NIX_MODE=1`) the config write guard refuses mutations with a message that already names the remedy. `config set` printed it plainly, but `plugins enable`, `plugins uninstall`, `update` and every other writer let it reach the root failure renderer, which framed the refusal as a crash: [openclaw] The CLI command failed. [openclaw] Reason: Config is externally managed ... [openclaw] Debug: set OPENCLAW_DEBUG=1 to include the stack trace. [openclaw] Try: openclaw doctor Doctor cannot lift an externally managed config, and there is no stack worth reading. Classify `ConfigReadOnlyError` and `NixModeConfigMutationError` as expected CLI conditions in the shared predicate, the same lean name-based classification the credential preflight errors use, so every writer prints the guard message as-is and `--json` keeps the canonical `cli_error` envelope.
What Problem This Solves
When an operator runs OpenClaw with an externally managed config (
OPENCLAW_CONFIG_READONLY=1, added in #140719) or underOPENCLAW_NIX_MODE=1, the config write guard refuses mutations with a message that already carries the remedy ("Edit the config in your external deployment source, then redeploy or restart OpenClaw as needed.").openclaw config setprinted that message plainly, butopenclaw plugins enable telegramon a fresh isolated state (observed live at71555bcbcb6) printed:Every writer that throws through to the root renderer (
plugins enable|disable|install|uninstall|update,openclaw update, doctor repairs) got the same crash framing. Doctor cannot lift an externally managed config, and there is no stack worth reading; the framing contradicts the guard's own guidance.Why This Change Was Made
isExpectedCliErrorinsrc/cli/failure-output.tsis the owner of "this is an operator condition, print the producer message as-is". It already classifies the Gateway credential preflight errors structurally by name (#142112) so the root renderer stays free of the config and transport stacks. This change addsConfigReadOnlyErrorandNixModeConfigMutationErrorfromsrc/config/config-write-guard.tsto that predicate with the same lean name check. The guard messages are already complete, and the--jsonpath keeps the canonicalcli_errorenvelope through the same predicate.config setkeeps its own catch; nothing else changes.User Impact
Immutable-config refusals now print exactly the guard message on every command, with exit code 1 and no stack-trace or Doctor hint. Non-refusal failures keep their crash framing.
Evidence
71555bcbcb6, built dist, isolated state,OPENCLAW_CONFIG_READONLY=1):openclaw plugins enable telegramprinted the six-line crash framing above.OPENCLAW_NIX_MODE=1and forplugins uninstall.src/cli/failure-output.test.ts: two new rows in the existing "routes $label through the shared expected-condition predicate without crash framing" table; both fail on unmodifiedmain(isExpectedCliErrorreturns false), pass with the fix; the file passes at 24 tests.node scripts/check-changed.mjs: pass. Autoreview (Codex, P0-P2): scoped-clean.Production LOC delta: +11 (one predicate with its contract comment, one line in the shared classifier).