Repository navigation
fix(plugins): install the local source the selected path names - #199874
wangmiao0668000666 wants to merge 2 commits into
Conversation
`openclaw plugins install "./selected/../plugin-b"` resolves the spec lexically before the filesystem. When `selected` is a directory symlink, the filesystem reads that name as `physical/plugin-b`, so the command installs a different, valid neighbouring plugin and reports success. Resolve the local spec parent through the existing fs-safe prefix traversal, which returns the physical ancestor plus the segments that do not exist yet. A spec whose parent chain is not created keeps the previous lexical result so "Plugin path not found" still names what the operator typed.
|
🦞👀 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 changesResolve local plugin source paths through physical parent directories while preserving whitespace trimming and existing not-found handling. Example: From /tmp/cwd, selected points to /tmp/physical/nested and both neighboring plugin-b directories contain valid plugins.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a concrete wrong-source installation bug still present on main; both prior findings are resolved, with no remaining actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe CLI source planner converts an install locator into a typed request consumed by the existing plugin validation, scanning, installation, and persistence owners. flowchart LR
A[Plugin install command] --> B[Source planner]
B --> C[Physical parent resolver]
C --> D[Local install request]
D --> E[Validation and security scan]
E --> F[Installation and persistence]
Technical reviewBest possible solution: Keep physical source selection in the existing planner and retain the three regressions protecting traversal, trimming, and invalid-parent handling. Do we have a high-confidence way to reproduce the issue? Current-main source establishes lexical collapse before filesystem selection, and the contributor supplies paired CLI results with distinct valid physical and decoy plugins; this review executed no target code. Is this the best way to solve the issue? The patch repairs selection at the existing owner using the pinned filesystem resolver, without changing downstream validation or installation policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6d6b7b7604d2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +32, Tests +68. Total +100 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel 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 15, 2026, 8:52 PM ET / November 16, 2026, 01:52 UTC (Revision 2). |
…hysically The physical resolver dropped two behaviors `resolveUserPath` provided for every existing caller: - surrounding whitespace was trimmed before home expansion, so `plugins install "/path/plugin "` still selected `/path/plugin`; - a regular file in the parent chain produced the structured "Plugin path not found" plan instead of throwing ENOTDIR. Keep the trim and the lexical fallback with `resolveUserPath`, and only replace the answer when the parent chain resolves physically.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Thanks for the work here. We're closing this along with the other open PRs that apply the same change one call site at a time. This series changes symlink, physical-path and literal-path handling at each command separately; path resolution policy belongs in one shared owner and needs a maintainer decision. Please open one issue (or one PR at the shared owner) that covers the whole pattern, with a reproduction of real user-visible harm, instead of separate per-site PRs. Further per-site variants of this pattern will be closed. |
What Problem This Solves
openclaw plugins install "./selected/../plugin-b"installs a different, valid neighbouring plugin and reports success. The install plan collapses the local spec lexically (resolveUserPath) before any filesystem call. Forselected -> physical/nested, the filesystem reads that name asphysical/plugin-b, while lexical normalization produces<cwd>/plugin-b.Distinct valid projects make this a successful operation on the wrong resource: the operator gets another plugin's code, manifest and capabilities installed under their chosen path.
User Impact
A local plugin install selects, validates, scans and copies the source the supplied path actually names. Ordinary paths,
~-prefixed paths, archives,file:specs, bundled lookups, surrounding-whitespace trimming and the existing "Plugin path not found" diagnostic keep their current behavior.Why This Change Was Made
Resolve the local spec parent through the existing fs-safe prefix traversal (
resolvePathPrefixSync) instead of the lexicalresolveUserPath. That returns the physical existing ancestor plus the segments that do not exist yet, so the result names the same directory the filesystem will use.Two existing
resolveUserPathbehaviors stay in place, so no previously accepted input changes:plugins install "/path/plugin "continues to select/path/plugin.Plugin path not foundplan instead of a rawENOTDIRthrow.Both are implemented by computing the lexical answer with
resolveUserPathfirst and only replacing it when the parent chain resolves physically without an unresolved..segment.Classification: behavior-completing. The fix reuses the shipped fs-safe owner that
src/cli/media-output.ts,src/cli/capability-cli/media-understanding-command.tsandsrc/logging/diagnostic-support-export.tsalready use for this class of input.Evidence
Actual repository CLI on Linux / Node 24.22.1, isolated
OPENCLAW_STATE_DIR(mode 700), synthetic fixtures, no network and no model.The wrong-source install
state/extensions/plugin-decoy<root>/cwd/plugin-b— the lexical sibling44e65317f2a5state/extensions/plugin-real<root>/physical/plugin-b— what the path namesThe base run prints
Installing to …/plugin-decoy…and exits 0: a successful install of the wrong plugin.The two input contracts
Both match main's behavior; the first version of this patch broke both, which is what the review caught.
Tests
src/cli/plugin-install-plan.test.tsadds three cases against the shared planner:selected/../selected-siblingselectsphysical/selected-sibling"<root>/plugin "trims to<root>/plugin<root>/file/child/pluginreturns the not-found planThe file's 9 tests pass with the fix.
oxfmt --checkclean on both files;oxlintclean on both files; line-cap ratchetOK: 2 changed source files; no new violations or over-cap growth; test-lines ratchet within allowance.skipIf(win32)), a live Gateway install of the resulting plugin, and exact-head hosted CI. A bundled-plugin config-validation error appears after the install step in this dist build and is unrelated to the source selection shown above.Isolated state only: the proof used throwaway
/tmpdirectories withchmod 700. No production Gateway, session, config, plugin install or token was touched.