Repository navigation
fix(cli): report plugin policy refusals as expected conditions - #125304
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 10:52 AM ET / 14:52 UTC. ClawSweeper reviewWhat this changesThe PR marks bundled-plugin policy refusals as expected CLI errors so terminal and JSON output show the existing remedy without crash, debug, Doctor, or generic-help framing. Merge readinessNo blocking correctness findings: this is a focused shared-renderer repair for misleading CLI failure framing. Exact-head CI is still incomplete; likely related person: steipete (high confidence from current and precursor CLI history). Priority: P2 Review scores
Verification
How this fits togetherOpenClaw resolves command ownership and plugin policy before its CLI entrypoints render human or JSON failures. The patch routes known policy outcomes through the shared expected-error renderer, leaving genuine operational errors on the existing crash path. flowchart LR
A[CLI invocation] --> B[Command and plugin policy resolution]
B --> C{Command allowed?}
C -- No --> D[Expected policy diagnostic]
C -- Yes --> E[Command execution]
D --> F[Human and JSON renderer]
F --> G[Actionable message and exit 1]
E --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +8, Tests +131. Total +139 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single shared expected-condition carrier, preserve lazy loading in the early CLI path, and merge only after exact-head CI is green. Do we have a high-confidence way to reproduce the issue? Yes—current main visibly converts the policy messages to ordinary errors before the generic formatter, and the PR body supplies isolated built-CLI before/after runs; this read-only review did not execute them. Is this the best way to solve the issue? Yes—the change extends the established shared expected-error boundary to both policy producers and both entrypoints, avoiding a parallel plugin-specific renderer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 793669c8f6dd. LabelsLabel changes:
Label justifications:
EvidenceWhat 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
|
ff4560e to
580dd4b
Compare
|
Merged via squash.
|
Closes #142111. ## What Problem This Solves When `--url` or `OPENCLAW_GATEWAY_URL` lacks matching explicit credentials, the CLI now prints the existing credential remedy directly. It no longer adds a command/startup failure banner or unrelated Doctor, debug, and help hints. ## Why This Change Was Made The change extends the shared expected-error predicate without importing the Gateway client. Credential enforcement, producer messages, exit code 1, and the canonical `cli_error` JSON structure remain intact. Human `nodes` commands now use that shared path. Command-owned machine error formats retain their existing handling. This builds on #125007, #125304, and #125556. ## User Impact Operators get the existing credential remedy without misleading crash advice. Credential rejection, exit status, and machine output remain intact. ## Evidence Verified full source CLI entry processes on pinned main `6e55c1df` and candidate `e785a1b6`, using isolated synthetic configuration and a loopback connection observer with no Gateway service: - Nine missing-credential cases made zero connections. Human stdout stayed empty; stderr contained the complete remedy. JSON contained one canonical error object. - Explicit token, password, and matching environment-token controls each reached the connection observer once, then reported the normal transport failure. - Devices, nodes, environment URL, debug, JSON, and credential-shaped text masking passed independent behavior acceptance. The masking control preserves the remedy; it does not promise an identical replacement string. - 22 shared-renderer tests and four entry-boundary controls passed on the current head. Four full-entry regressions passed on the original candidate; unchanged regression/producer inputs and fresh current-head CLI proof justify reuse after the contributor rebase. Three process cases and the added classification unit case failed on pinned main for the intended reason. - Focused formatting, syntax lint, line/assertion checks, and `git diff --check` passed. Full CI owns broad typechecks and suites. Fresh independent AutoReview found no actionable findings. Example candidate stderr (config path normalized): ```text gateway url override requires explicit credentials Fix: pass --token or --password *** --url (or gatewayToken in tools). For the default local or SSH-tunneled Gateway, remove --url to use the configured target. Config: <isolated-config> ``` The `***` in the remedy is existing console redaction. No live Gateway, external credential, or production state was used. Implementation and regression coverage by @DasX. AI-assisted verification. CI history: the original head hit a Matrix native-addon download HTTP500. A stale-head rerun collided with the PR concurrency group and cancelled the first rebased run; both attempts were reconciled before one current-head rerun. [Current-head run34223670630, attempt2](https://github.com/openclaw/openclaw/actions/runs/34223670630/attempts/2) completed with one child failure: a120-second timeout in Telegram sticker model selection ([job102058607784](https://github.com/openclaw/openclaw/actions/runs/34223670630/job/102058607784)). All other children passed or skipped. This is recorded separately from the CLI behavior proof; it is not reported as green CI. CI causality was checked against a later natural recurrence: [run34228376739, job102069062439](https://github.com/openclaw/openclaw/actions/runs/34228376739/job/102069062439) timed out in the same first MiniMax case at128626ms. Its tested merge `4f921a82` has the old CLI classifier and neither added CLI test, with unchanged relevant selector, loader, setup, and lock source. It ran the same selected file order on different Node, CPU, memory, and cache inputs. This is independent recurrence evidence, not a matching main-push run or exact main A/B experiment. The changed predicate runs only in CLI error handling and adds no import or initialization work to the failing selection path. The retained main profile also measures expensive plugin loading. Together these establish that the failed child is unrelated to this patch; the exact original157482ms duration remains unattributed. The original CI restored its Node compile cache; only its transform-cache restore missed. Main-only comparisons used fresh Node caches and do not reproduce that cache state. Any landing exception uses the guarded, exact-run approval path. Co-authored-by: Ayaan Zaidi <[email protected]>
) Closes openclaw#142111. ## What Problem This Solves When `--url` or `OPENCLAW_GATEWAY_URL` lacks matching explicit credentials, the CLI now prints the existing credential remedy directly. It no longer adds a command/startup failure banner or unrelated Doctor, debug, and help hints. ## Why This Change Was Made The change extends the shared expected-error predicate without importing the Gateway client. Credential enforcement, producer messages, exit code 1, and the canonical `cli_error` JSON structure remain intact. Human `nodes` commands now use that shared path. Command-owned machine error formats retain their existing handling. This builds on openclaw#125007, openclaw#125304, and openclaw#125556. ## User Impact Operators get the existing credential remedy without misleading crash advice. Credential rejection, exit status, and machine output remain intact. ## Evidence Verified full source CLI entry processes on pinned main `12094868` and candidate `e785a1b6`, using isolated synthetic configuration and a loopback connection observer with no Gateway service: - Nine missing-credential cases made zero connections. Human stdout stayed empty; stderr contained the complete remedy. JSON contained one canonical error object. - Explicit token, password, and matching environment-token controls each reached the connection observer once, then reported the normal transport failure. - Devices, nodes, environment URL, debug, JSON, and credential-shaped text masking passed independent behavior acceptance. The masking control preserves the remedy; it does not promise an identical replacement string. - 22 shared-renderer tests and four entry-boundary controls passed on the current head. Four full-entry regressions passed on the original candidate; unchanged regression/producer inputs and fresh current-head CLI proof justify reuse after the contributor rebase. Three process cases and the added classification unit case failed on pinned main for the intended reason. - Focused formatting, syntax lint, line/assertion checks, and `git diff --check` passed. Full CI owns broad typechecks and suites. Fresh independent AutoReview found no actionable findings. Example candidate stderr (config path normalized): ```text gateway url override requires explicit credentials Fix: pass --token or --password *** --url (or gatewayToken in tools). For the default local or SSH-tunneled Gateway, remove --url to use the configured target. Config: <isolated-config> ``` The `***` in the remedy is existing console redaction. No live Gateway, external credential, or production state was used. Implementation and regression coverage by @DasX. AI-assisted verification. CI history: the original head hit a Matrix native-addon download HTTP500. A stale-head rerun collided with the PR concurrency group and cancelled the first rebased run; both attempts were reconciled before one current-head rerun. [Current-head run34223670630, attempt2](https://github.com/openclaw/openclaw/actions/runs/34223670630/attempts/2) completed with one child failure: a120-second timeout in Telegram sticker model selection ([job102058607784](https://github.com/openclaw/openclaw/actions/runs/34223670630/job/102058607784)). All other children passed or skipped. This is recorded separately from the CLI behavior proof; it is not reported as green CI. CI causality was checked against a later natural recurrence: [run34228376739, job102069062439](https://github.com/openclaw/openclaw/actions/runs/34228376739/job/102069062439) timed out in the same first MiniMax case at128626ms. Its tested merge `4f921a82` has the old CLI classifier and neither added CLI test, with unchanged relevant selector, loader, setup, and lock source. It ran the same selected file order on different Node, CPU, memory, and cache inputs. This is independent recurrence evidence, not a matching main-push run or exact main A/B experiment. The changed predicate runs only in CLI error handling and adds no import or initialization work to the failing selection path. The retained main profile also measures expensive plugin loading. Together these establish that the failed child is unrelated to this patch; the exact original157482ms duration remains unattributed. The original CI restored its Node compile cache; only its transform-cache restore missed. Main-only comparisons used fresh Node caches and do not reproduce that cache state. Any landing exception uses the guarded, exact-run approval path. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes an issue where plugin-policy refusals were rendered as CLI crashes. On a fresh profile, invoking a bundled plugin command that is disabled by default printed the correct enablement sentence inside a false crash title, stack-debug hint, Doctor recommendation, and generic help hint. The same framing affected
plugins.allowexclusions, explicit plugin disablement, parent-plugin allowlist guidance, runtime slash commands used as CLI commands, and plugin agent tools used as CLI commands.The impact is broad on the default path: an isolated
plugins list --jsonrun at the base SHA reported 65 disabled bundled plugins out of 149 total.Related: #124892 established the pre-rendered expected-condition seam for parse guidance. #125007 is the open follow-up for missing Gateway credentials.
AI-assisted: Codex. The source, tests, built output, isolated profiles, and captured streams were inspected directly.
Why This Change Was Made
The landed
CliParseErrorcarrier represented a broader contract than its name: canonical human output, canonical machine output, an already-written flag, and exemption from crash framing and fatal hooks. This change renames it toExpectedCliError, keeps the parse-specific factories parse-specific, and addsisExpectedCliErroras the one renderer predicate. Both plugin-policy producer sites now wrap their existing message in that carrier.This leaves one expected-condition concept rather than reusing a misleading parse name or adding a parallel plugin-policy type. No compatibility alias remains: the type is an internal, unshipped CLI implementation detail introduced by #124892.
The design composes with #125007: after rebasing, that PR can extend
isExpectedCliErrorwith its structuredGatewayCredentialsRequiredErrorclassifier while preserving the Gateway error'smethodandconfigPathfields. Its command-local rethrow work is complementary; the expected textual conflicts are limited to the shared renderer, its tests, and the legacy executable entrypoint.No policy message changed. The JSON envelope and message bytes did not change. Exit status remains 1.
Docs-link verdict
No
Docs:line was added. The seven policy/tool messages already state their exact remedy, while a generic/pluginslink is not uniformly relevant to runtime slash commands and agent tools. Adding it would make the output noisier without improving the next action.User Impact
Operators now see the policy sentence by itself. For example,
openclaw workboard liston a fresh profile says that Workboard is disabled by default and gives the exact enable command, without claiming the CLI crashed or suggesting stack inspection and Doctor.Human and
--jsonforms still exit 1. JSON stdout retains{ ok: false, error: { type: "cli_error", message } }, and stderr now contains only the same canonical message.Evidence
Built CLI before/after
Every case used its own scratch
OPENCLAW_STATE_DIR, anopenclaw.jsoncontaininggateway.mode=localplus a free non-18789 port,OPENCLAW_SKIP_CHANNELS=1, and Discord/Twilio credential variables unset. Stdout and stderr were captured separately and inspected.workboard listplugins.allowexclusionworkboard listwithallow=[browser]enabled=falsebrowser statusvoicecall statuswithallow=[voicecall]dreamingreef statusindependently proved a third disabled-by-default plugin.dist/index.js workboard listalso exited 1 with the exact message only, covering the legacyThe CLI command failedentrypoint.For all six captured commands:
Reason:,OPENCLAW_DEBUG,Stack:, Doctor hint, or generic help hint;error.message.Full message-surface sweep
plugins.allowexclusionplugins.entries.<id>.enabled=falseThe last two templates were an audit surprise:
canvasis an enabled-by-default agent tool, not another disabled-plugin case. The renderer fix covers them because it wraps every non-null policy result.Other CLI plain-error producers were left unchanged with evidence: container/profile argument validation is rendered directly by
src/entry.tsand exits 2; container execution failures are genuine operational failures; unrelated command-local validation remains with its owner pending a concrete crash-framing reproduction. Missing Gateway credentials remain in #125007.Tests and gates
run-main.exitcases failed because every policy result was a plainErrorrather than the expected-condition carrier.node scripts/run-vitest.mjs src/cli/run-main.test.ts src/cli/run-main.exit.test.ts src/cli/failure-output.test.ts src/entry.run-main.test.ts src/cli/program/error-output.test.ts— 309 passed across three routed shards.OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs— passed the complete localcore, coreTestsplan, including typechecks, type-aware lint, formatting, guards, dead exports, and import cycles.pnpm build— passed on the exact committed tree..agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output— clean; no accepted/actionable findings.The first unqualified
node scripts/check-changed.mjsattempt followed the configured Blacksmith Testbox route, buttbx_01m081fmvdnx8zg6msx7hrhcgtnever allocated an IP or Actions run and was stopped. It produced no test verdict and is not counted as proof.Production LOC: +25/-17 (net +8). Tests: +178/-47 (net +131).