Skip to content

fix(cli): print immutable-config refusals without crash framing - #143140

Merged
steipete merged 1 commit into
mainfrom
fix/immutable-config-cli-framing
Sep 9, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/immutable-config-cli-framing

Conversation

@steipete

@steipete steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

When an operator runs OpenClaw with an externally managed config (OPENCLAW_CONFIG_READONLY=1, added in #140719) or under OPENCLAW_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 set printed that message plainly, but openclaw plugins enable telegram on a fresh isolated state (observed live at 71555bcbcb6) printed:

[openclaw] The CLI command failed.
[openclaw] Reason: Config is externally managed (`OPENCLAW_CONFIG_READONLY=1`), so OpenClaw treats openclaw.json as immutable.
Edit the config in your external deployment source, then redeploy or restart OpenClaw as needed.
[openclaw] Debug: set OPENCLAW_DEBUG=1 to include the stack trace.
[openclaw] Try: openclaw doctor
[openclaw] Help: openclaw --help

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

isExpectedCliError in src/cli/failure-output.ts is 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 adds ConfigReadOnlyError and NixModeConfigMutationError from src/config/config-write-guard.ts to that predicate with the same lean name check. The guard messages are already complete, and the --json path keeps the canonical cli_error envelope through the same predicate. config set keeps 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

  • Before (main 71555bcbcb6, built dist, isolated state, OPENCLAW_CONFIG_READONLY=1): openclaw plugins enable telegram printed the six-line crash framing above.
  • After (this branch, built dist, same command): prints only the guard message (two lines), exit 1; the same holds for OPENCLAW_NIX_MODE=1 and for plugins 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 unmodified main (isExpectedCliError returns 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).

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 9, 2026 13:54
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS maintainer Maintainer-authored PR labels Sep 9, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 10:26 AM ET / 14:26 UTC (Revision 2).

ClawSweeper review

What this changes

The 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
Reviewed head: 41e6da52a584788c2fb22e65a6d702490846b11a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant runtime observations, meaningful regression cases, and no actionable correctness or security findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body reports built-CLI plugin enable and uninstall runs in isolated state under both immutable modes, with the shared renderer producing the guard remedy and exit 1 after the fix. These observations directly exercise the changed output boundary; focused regression tests are supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports built-CLI plugin enable and uninstall runs in isolated state under both immutable modes, with the shared renderer producing the guard remedy and exit 1 after the fix. These observations directly exercise the changed output boundary; focused regression tests are supplemental.
Evidence reviewed 8 items Verified introduced change: The pinned base-to-head diff adds only two immutable-config error names to the existing expected-error classifier and two regression cases; it does not modify enforcement or configuration.
Still necessary on fetched main: The fetched main classifier recognizes expected CLI, Gateway credential, and transport errors but neither immutable-config error. Its fallback still adds the failure banner and Doctor/debug hints.
Producer and rendering contract: Both guard errors extend Error, assign the exact names checked by the patch, and carry deployment-specific recovery guidance. The root entry renderer preserves failure exit status and the canonical JSON envelope. The plugin-enable guard runs before plugin mutation.
Findings None None.
Security None None.

How this fits together

Configuration 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +11, Tests +9. Total +20 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 0 +11
Tests 1 9 0 +9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 20 0 +20

Review metrics

None.

Technical review

Best 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.

Labels

Label justifications:

  • P3: This improves CLI diagnostic guidance while retaining the existing refusal and failure status.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 captured body reports built-CLI plugin enable and uninstall runs in isolated state under both immutable modes, with the shared renderer producing the guard remedy and exit 1 after the fix. These observations directly exercise the changed output boundary; focused regression tests are supplemental.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports built-CLI plugin enable and uninstall runs in isolated state under both immutable modes, with the shared renderer producing the guard remedy and exit 1 after the fix. These observations directly exercise the changed output boundary; focused regression tests are supplemental.

Evidence

What I checked:

  • Verified introduced change: The pinned base-to-head diff adds only two immutable-config error names to the existing expected-error classifier and two regression cases; it does not modify enforcement or configuration. (src/cli/failure-output.ts:94, 41e6da52a584)
  • Still necessary on fetched main: The fetched main classifier recognizes expected CLI, Gateway credential, and transport errors but neither immutable-config error. Its fallback still adds the failure banner and Doctor/debug hints. (src/cli/failure-output.ts:94, e7567735b316)
  • Producer and rendering contract: Both guard errors extend Error, assign the exact names checked by the patch, and carry deployment-specific recovery guidance. The root entry renderer preserves failure exit status and the canonical JSON envelope. The plugin-enable guard runs before plugin mutation. (src/config/config-write-guard.ts:10, 41e6da52a584)
  • Documented operator remedy: The config reference explicitly says plugin mutations and Doctor repairs are blocked in immutable mode and directs operators to change their external deployment source. Public docs: docs/cli/config.md. (docs/cli/config.md:35, 41e6da52a584)
  • Behavioral regression coverage: The complete test file was inspected. The added table rows instantiate the real guard errors and verify plain producer guidance even with debug enabled; existing cases retain ordinary failure framing. Tests were not executed during this read-only review. (src/cli/failure-output.test.ts:224, 41e6da52a584)
  • Supplied real CLI observations: The complete captured PR body at sourceRevision 4e23d1aff791d78f062713c94e005aa7c6db982c27470d15d11a9c0742ee89eb describes built-distribution runs in isolated state: plugin enable printed crash framing before the fix and only the guard remedy with exit 1 afterward, with Nix mode and plugin uninstall also checked. These are contributor-reported runtime observations, not reviewer-executed tests.

Likely related people:

  • DasX: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • sallyom: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-09T13:59:25.812Z sha 46cd201 :: needs maintainer review before merge. :: none

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.
@steipete
steipete force-pushed the fix/immutable-config-cli-framing branch from 46cd201 to 41e6da5 Compare September 9, 2026 14:21
@steipete
steipete merged commit ae65c40 into main Sep 9, 2026
174 checks passed
@steipete
steipete deleted the fix/immutable-config-cli-framing branch September 9, 2026 14:36
@steipete

steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 9, 2026
…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)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 10, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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