Skip to content

fix(plugins): install the local source the selected path names - #199874

Closed
wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/plugins-install-physical-path
Closed

wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/plugins-install-physical-path

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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. For selected -> physical/nested, the filesystem reads that name as physical/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 lexical resolveUserPath. 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 resolveUserPath behaviors stay in place, so no previously accepted input changes:

  • Surrounding whitespace is still trimmed before home expansion. plugins install "/path/plugin " continues to select /path/plugin.
  • A regular file in the parent chain still yields the structured Plugin path not found plan instead of a raw ENOTDIR throw.

Both are implemented by computing the lexical answer with resolveUserPath first 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.ts and src/logging/diagnostic-support-export.ts already 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

fixture: <root>/physical/nested, <root>/cwd, <root>/cwd/selected -> ../physical/nested
         <root>/physical/plugin-b  (id: plugin-real)
         <root>/cwd/plugin-b       (id: plugin-decoy)
command: node dist/entry.js plugins install "./selected/../plugin-b" --force --accept-capabilities
Run Reported install target Source actually selected
Base (main source, same tree) state/extensions/plugin-decoy <root>/cwd/plugin-b — the lexical sibling
Head 44e65317f2a5 state/extensions/plugin-real <root>/physical/plugin-b — what the path names

The base run prints Installing to …/plugin-decoy… and exits 0: a successful install of the wrong plugin.

The two input contracts

1. trim:    plugins install "/tmp/v3/plain/solo "    -> Installing to …/plugin-solo…
2. ENOTDIR: plugins install "/tmp/v3/file/child/plugin" -> Plugin path not found: /tmp/v3/file/child/plugin

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.ts adds three cases against the shared planner:

Case main first patch head
selected/../selected-sibling selects physical/selected-sibling ✗ (lexical sibling) ✓ ✓
"<root>/plugin " trims to <root>/plugin ✓ ✗ ✓
<root>/file/child/plugin returns the not-found plan ✓ ✗ ✓

The file's 9 tests pass with the fix.

  • Gates: oxfmt --check clean on both files; oxlint clean on both files; line-cap ratchet OK: 2 changed source files; no new violations or over-cap growth; test-lines ratchet within allowance.
  • Not tested: Windows (junction semantics are unexercised; the new tests are 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.
node node_modules/vitest/vitest.mjs run \
  --config test/vitest/vitest.cli.config.ts \
  src/cli/plugin-install-plan.test.ts --maxWorkers=1

Isolated state only: the proof used throwaway /tmp directories with chmod 700. No production Gateway, session, config, plugin install or token was touched.

`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.
@clawsweeper

clawsweeper Bot commented Nov 16, 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.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Nov 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

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

  • Before: Installing ./selected/../plugin-b selects /tmp/cwd/plugin-b.
  • After: The same command selects /tmp/physical/plugin-b.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful repair with relevant CLI evidence and distinct regression coverage; Windows behavior remains unexercised and exact-head CI is pending.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied Linux CLI output exercises the changed source planner with two valid neighboring plugins and shows this head selecting plugin-real instead of plugin-decoy; additional CLI cases demonstrate preserved trimming and invalid-parent diagnostics, without claiming later Gateway activation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A successful local installation can install another valid plugin instead of the source named by the operator's path.
Reason: Correct resource selection is an existing installation contract, and the change preserves established input handling without adding configuration or policy.

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
Reviewed head: 44e65317f2a5ad76b10b56833de59176e4369d5a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Local source selection in the shared plugin install planner keeps the original intent (6e25935: The merged source-planning consolidation unified supported installation paths while preserving local/file isolation and downstream lifecycle ownership.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +32, Tests +68. Total +100 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 33 1 +32
Tests 1 69 1 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 102 2 +100

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A local install can successfully select the wrong valid plugin, but the trigger requires a directory symlink followed by parent traversal.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-16T01:30:21.148Z sha da23b30 :: needs changes before merge. :: [P2] Preserve surrounding-whitespace normalization before traversal | [P3] Return a planner error for invalid parent traversal

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.
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 16, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants