fix(cli): reject missing plugin ids before config writes#73554
Conversation
Greptile SummaryThis PR fixes a bug where Confidence Score: 5/5Safe to merge — fix is well-scoped and tests cover the critical paths. Only a P2 test symmetry gap found; production logic is correct and the id-over-name priority is properly tested. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/cli/plugins-cli.policy.test.ts
Line: 119-132
Comment:
**Missing `setPluginEnabledInConfig` assertion in disable rejection test**
The `enable` rejection test explicitly asserts `expect(enablePluginInConfig).not.toHaveBeenCalled()`, but the symmetric `disable` rejection test doesn't assert that `setPluginEnabledInConfig` was not called. Adding this assertion would close the gap and make both tests structurally equivalent.
```suggestion
expect(runtimeErrors).toContain(
"Plugin not found: missing-plugin. Run `openclaw plugins list` to see installed plugins.",
);
expect(setPluginEnabledInConfig).not.toHaveBeenCalled();
expect(writeConfigFile).not.toHaveBeenCalled();
expect(refreshPluginRegistry).not.toHaveBeenCalled();
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "fix(cli): prefer exact plugin ids for po..." | Re-trigger Greptile |
a4ccd5a to
0f43726
Compare
|
Codex review: needs changes before merge. Summary Reproducibility: yes. Source inspection on current main shows both policy commands call config mutation and Next step before merge Security Review findings
Review detailsBest possible solution: Use the registry-backed canonical plugin-id normalizer for policy command input, then reject only truly unknown ids before config mutation. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows both policy commands call config mutation and Is this the best way to solve the issue? No, not yet. The pre-write validation boundary is right, but the PR should canonicalize through the manifest-aware registry alias contract instead of the static fallback. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 55c738ad4bed. |
|
Human verification update for Verified scenarios:
Edge cases checked:
What I did not verify:
|
f762801 to
daeda6e
Compare
|
Hello @vincentkoc |
2591e5e to
6003f06
Compare
6003f06 to
c5d9fb6
Compare
|
The missing-id guard is directionally right, but the exact-id check in The repo still normalizes provider/channel/legacy ids such as I do not think this is ready for |
hxy91819
left a comment
There was a problem hiding this comment.
The missing-id guard is directionally right, but the exact-id check in src/cli/plugins-cli.ts:536 / src/cli/plugins-cli.ts:578 regresses current compatibility ids.
The bug this PR is trying to fix is real: plugins enable <missing-id> / plugins disable <missing-id> should fail before writing stale plugins.entries.<id> config. But I do not think this is the best fix as written, because it also rejects ids that current OpenClaw code and shipped manifests still treat as valid compatibility aliases.
Evidence:
src/plugins/config-state.ts:38still normalizes compatibility ids such asopenai-codex,google-gemini-cli, andminimax-portal-authback to canonical plugin ids.src/plugins/plugin-registry.test.ts:293proves registry contribution aliases such as provider ids and channel ids normalize back to the owning plugin id.src/plugins/config-state.test.ts:134locks in legacy plugin-id normalization.extensions/openai/openclaw.plugin.json:7,extensions/google/openclaw.plugin.json:7, andextensions/minimax/openclaw.plugin.json:7still advertise those compatibility ids in current manifests.
Please resolve the user-supplied id through the existing alias-aware normalizer before rejecting it, then validate the canonical plugin id. Also add command coverage that plugins enable|disable still accept compatibility ids while still failing for truly unknown ids.
Given that regression, I do not think this is ready for /prepare-pr yet.
|
Thanks, fixed in ee7433f52a. The enable/disable guard now resolves the CLI argument through the existing Added command coverage for both Validation run:
|
ee5b670 to
ee7433f
Compare
|
Tested this PR locally. Before/after regression check:
|
38c7aef to
04a3bf6
Compare
04a3bf6 to
f0d3e61
Compare
|
Merged via squash.
Thanks @ai-hpc! |
) Merged via squash. Prepared head SHA: f0d3e61 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
) Merged via squash. Prepared head SHA: f0d3e61 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
) Merged via squash. Prepared head SHA: f0d3e61 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
) Merged via squash. Prepared head SHA: f0d3e61 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
) Merged via squash. Prepared head SHA: f0d3e61 Co-authored-by: ai-hpc <[email protected]> Co-authored-by: hxy91819 <[email protected]> Reviewed-by: @hxy91819
Summary
openclaw plugins enable <id>andplugins disable <id>accepted nonexistent plugin ids and could write staleplugins.entries.<id>config.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
Regression Test Plan (if applicable)
src/cli/plugins-cli.policy.test.tsplugins enable missing-pluginandplugins disable missing-pluginexit 1 and do not call config write or registry refresh seams.User-visible / Behavior Changes
openclaw plugins enable <missing-id>andopenclaw plugins disable <missing-id>now fail with a clear plugin-not-found error and do not mutateopenclaw.json.Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/ARepro + Verification
Environment
plugins.entriespolicy configSteps
openclaw plugins enable totally-fake-plugin-xyz.openclaw.json.openclaw plugins disable totally-fake-plugin-xyz.Expected
plugins.entries.<id>entry is written.Actual
plugins.entries.<id> = { enabled: true }and exit 0.Evidence
Attach at least one:
Local verification:
pnpm test src/cli/plugins-cli.policy.test.ts -- --reporter=verbosepnpm test src/cli/plugins-cli.policy.test.ts src/cli/plugins-cli.list.test.ts src/cli/plugins-cli.uninstall.test.ts src/cli/plugins-cli.install.test.ts src/cli/plugins-config.test.ts src/plugins/enable.test.ts -- --reporter=verbosepnpm check:changed -- --base upstream/maingit diff --checkHuman Verification (required)
plugins enableandplugins disablereject before config writes; adjacent plugin CLI tests still pass.Review Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations