Repository navigation
fix: local path commands pick a neighboring file when a symlinked folder is followed by .. - #200031
Conversation
…nd `..` `path.resolve` folds `folder/..` as text, but the OS applies `..` to the folder's real location. With `selected -> ../physical/nested`, `selected/../plugin-b` installed, read or wrote `./plugin-b` instead of `physical/plugin-b`, and the command reported success. Add one resolver in src/infra/home-dir.ts for paths a command is about to open or write (`resolveFilesystemPath`, and `resolveUserFilesystemPath` with trimming and `~`). Only a symlink directly before `..` is followed; every other segment keeps its spelling, so `plugins install --link` still records a final symlink as typed. Paths without `..`, and Windows, resolve as before. A missing, unreadable or non-folder segment before `..` leaves the path unfolded so the I/O reports the OS error. Route plugin install (local path, archive, npm-pack, local git, marketplace path), diagnostics export, agents set-identity, infer file inputs and outputs (replacing the per-command fix from openclaw#192718) and the templates project commands through it. Config-stored paths keep resolveUserPath. Closes openclaw#199950
|
🦞👀 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: blocked before merge. What this changesThis PR shares filesystem-aware resolution across local command paths while preserving final symlinks and existing stored-path handling. Example: From /tmp/demo/cwd, selected points to ../physical/nested and the user runs plugins install ./selected/../plugin-b.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains This PR addresses a current wrong-file selection bug, resolves the earlier findings, and has passing current-head CI; the explicitly reserved shared-owner decision remains open. Priority: P2 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherCommand handlers pass local input and output paths through the shared resolver before existing installers, media readers, backup operations, and artifact writers perform their normal checks and I/O. flowchart TD
A[Command path input] --> B[Existing literal or home expansion contract]
B --> C[Shared filesystem path resolver]
C --> D[Existing source and containment checks]
D --> E[Filesystem read or write]
E --> F[Command result]
Technical reviewBest possible solution: Approve the opt-in shared command-path resolver while retaining existing stored-path resolution and downstream safety checks. Do we have a high-confidence way to reproduce the issue? Current-main source establishes lexical collapse before I/O, and the contributor supplies matching built-CLI before/after results; this read-only review executed no target code. Is this the best way to solve the issue? The smallest complete fix is shared resolution before lexical collapse at the affected I/O boundaries, preserving final symlinks and existing safety owners; this PR implements that shape without changing the stored-path resolver. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2516bca9fdb8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +92, Tests +174, Docs +6. Total +272 across 25 files. Added test files: 1. 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. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 (2 earlier review cycles)
Reviewed November 16, 2026, 11:25 AM ET / 16:25 UTC (Revision 3). |
When a segment before `..` was missing, unreadable or a file, the resolver returned the unfolded path and relied on the I/O to fail. Later steps fold it again: the media attachment cache calls path.resolve, so `infer audio transcribe --file missing/../memo.wav` transcribed the lexical neighbor `./memo.wav`. The loop also dropped a trailing `/` or `/.`, so `link/../memo.wav/` read a regular file. The audio/video resolver this replaced rejected all three. Throw the OS error (ENOENT, ENOTDIR, EACCES) at the resolver, and require a trailing `/` or `/.` to name a directory when it exists. Plugin install and `--marketplace` treat an untraversable spec as not a local path and keep classifying it; template source reading keeps reporting a diagnostic, and template validation labels discovery failures with the lexical spelling. Make the `--link` install row assert the linked validate-in-place call, the path recorded in plugins.load.paths, instead of repeating the copy row. Move the audio/video `--file` path tests into capability-cli.media-paths.test-support.ts so capability-cli.test.ts does not grow past its line cap.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…nked folder and `..` `backup create --output` and `backup restore --target` resolved their path with `path.resolve`, so with `selected -> ../physical/nested`, `selected/../backup.tar.gz` was written to `./backup.tar.gz` and `--target selected/../restored` extracted into `./restored`. Route `resolveBackupArchivePath` (`--output`, `--target`, `<archive>`) through the shared resolver and drop the archive-only copy of this fix in backup-verify (openclaw#197688). An untraversable path fails as `Could not resolve <label>: <OS error>`. `backup verify`/`restore` report the archive path the filesystem opened. `plugins install` names the typed path and the OS error when a folder before `..` is missing, instead of `Plugin path not found: undefined`.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…der is followed by `..` (openclaw#200031) * fix: local path commands pick a neighbor through a symlinked folder and `..` `path.resolve` folds `folder/..` as text, but the OS applies `..` to the folder's real location. With `selected -> ../physical/nested`, `selected/../plugin-b` installed, read or wrote `./plugin-b` instead of `physical/plugin-b`, and the command reported success. Add one resolver in src/infra/home-dir.ts for paths a command is about to open or write (`resolveFilesystemPath`, and `resolveUserFilesystemPath` with trimming and `~`). Only a symlink directly before `..` is followed; every other segment keeps its spelling, so `plugins install --link` still records a final symlink as typed. Paths without `..`, and Windows, resolve as before. A missing, unreadable or non-folder segment before `..` leaves the path unfolded so the I/O reports the OS error. Route plugin install (local path, archive, npm-pack, local git, marketplace path), diagnostics export, agents set-identity, infer file inputs and outputs (replacing the per-command fix from openclaw#192718) and the templates project commands through it. Config-stored paths keep resolveUserPath. Closes openclaw#199950 * fix: reject untraversable paths instead of returning them unfolded When a segment before `..` was missing, unreadable or a file, the resolver returned the unfolded path and relied on the I/O to fail. Later steps fold it again: the media attachment cache calls path.resolve, so `infer audio transcribe --file missing/../memo.wav` transcribed the lexical neighbor `./memo.wav`. The loop also dropped a trailing `/` or `/.`, so `link/../memo.wav/` read a regular file. The audio/video resolver this replaced rejected all three. Throw the OS error (ENOENT, ENOTDIR, EACCES) at the resolver, and require a trailing `/` or `/.` to name a directory when it exists. Plugin install and `--marketplace` treat an untraversable spec as not a local path and keep classifying it; template source reading keeps reporting a diagnostic, and template validation labels discovery failures with the lexical spelling. Make the `--link` install row assert the linked validate-in-place call, the path recorded in plugins.load.paths, instead of repeating the copy row. Move the audio/video `--file` path tests into capability-cli.media-paths.test-support.ts so capability-cli.test.ts does not grow past its line cap. * fix: backup output and restore target pick a neighbor through a symlinked folder and `..` `backup create --output` and `backup restore --target` resolved their path with `path.resolve`, so with `selected -> ../physical/nested`, `selected/../backup.tar.gz` was written to `./backup.tar.gz` and `--target selected/../restored` extracted into `./restored`. Route `resolveBackupArchivePath` (`--output`, `--target`, `<archive>`) through the shared resolver and drop the archive-only copy of this fix in backup-verify (openclaw#197688). An untraversable path fails as `Could not resolve <label>: <OS error>`. `backup verify`/`restore` report the archive path the filesystem opened. `plugins install` names the typed path and the OS error when a folder before `..` is missing, instead of `Plugin path not found: undefined`. * chore: restart CI after PostgreSQL conformance runner timeout
) Resolve filesystem inputs before collapsing parent segments while retaining final-link spelling. Route stable CLI media, plugin installation, backup, diagnostic export, identity and template consumers through the existing home-path owner. Stable adaptation keeps backup errors in the existing Error contract with cause, and keeps media reads at their current owner. Preserve template lstat policy and avoid unrelated newer architecture. (cherry picked from commit 6f5d3b3) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit dc61014268519160b052eac7ca06d990dba5a415)
…94251) fix(infer): stop video runs on Ctrl+C `openclaw infer video` dropped its execution context, and with it the cancel signal, so Ctrl+C left the provider request open until the CLI was force-killed about 2 seconds later. The existing execution context is now passed through, as audio already does. Uninterrupted runs are unchanged. Evidence: built CLI with a real MP4 against a slow local video-provider fixture, twice per ref. Main needed SIGKILL after about 2,090 ms; with this change the CLI exits with 130 in under 100 ms and the HTTP request closes within 1.1 ms. Uninterrupted output and request bodies are identical. Details: openclaw#194251 (comment). Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 3af1447) Release adaptation: Forward video execution signal/assertCurrent and move existing guarded fetch/process scope to shared file owner. Retain baseline audio CLI and filesystem resolution: excluded HOLD audio/path migration not imported. Only13-line cancel regression, no fixture refactor. Follow-up dispositions: 577dd00 fix: send infer audio/video --model files only to the requested model (openclaw#190287); bcb47e8 feat(google): add Nano Banana 2.1 image model as the default (openclaw#200468); 6f5d3b3 fix: local path commands pick a neighboring file when a symlinked folder is followed by `..` (openclaw#200031); 3577724 fix(auth): only the running Gateway refreshes shared OAuth sign-ins (openclaw#198214); 81daea9 fix(cli): run infer model run through the Gateway that owns state (openclaw#198141); 22b1aac fix(media): cancel interrupted attachment downloads (openclaw#194399); e43ec1e fix(infer): cancel interrupted image descriptions (openclaw#194391) Validation: Baseline canceled-video assertion fails with16controls passing; candidate17/17passes,194251-green.log. Existing audio cancellation and workspace/cleanup behavior retained. Real MP4/CLI interrupt proof remains upstream-attributed, not locally rerun. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 853a96335df6193815789ebcc02d38af11123fcf) (cherry picked from commit 2ea2570de7f13823a8174590bfddfbfabdbcd915)
Closes #199950
What Problem This Solves
Fixes:
plugins install,gateway diagnostics export --output,backup create --output,backup restore --target,agents set-identity, theinferfile inputs and outputs, andtemplatescommands read or write a different, valid file than the one the path names, and report success, when the path goes through a symlinked folder followed by..(for example./selected/../plugin-bwithselected -> ../physical/nested).User Impact
User impact: on macOS and Linux, these commands open the same file that
lsorcatshows for the same path. Paths without a..segment, and every path on Windows, resolve exactly as before. A symlink at the end of the path keeps its spelling, soplugins install --link ./link-to-pluginstill records the link and follows it when its target changes.Visible differences:
..does not exist or is a file (missing/../x,notes.txt/../x), the command fails with the operating system's error instead of quietly using./x.plugins installreports it asPlugin path not found: <typed path> (<OS error>).backup verifyandbackup restorereport the archive path the filesystem opened (physical/backup.tar.gz) rather than the typedlink/../backup.tar.gzspelling.Why This Change Was Made
The paths were folded with
path.resolve, which removesfolder/..as text before the filesystem is consulted. The OS applies..to the folder's real location, so the two answers differ whenfolderis a symlink.One shared resolver in
src/infra/home-dir.ts, next toresolveUserPath, serves the affected commands:resolveFilesystemPathreplacespath.resolvefor a path that is about to be opened or written.resolveUserFilesystemPathreplacesresolveUserPath(trimming and~expansion stay the same).Only when a
..segment is present does the resolver check the segment before it: a symlink is replaced by its target, then..applies. Other segments stay as typed. If that segment is missing, unreadable or not a folder, the resolver throws the operating system's error (ENOENT,ENOTDIR,EACCES), so no later step can fold the path back to./x. A trailing/or/.on such a path must name a folder, as the OS requires.plugins installand--marketplacetreat a spec the filesystem cannot traverse as not a local path and keep classifying it as before (npm, git, URL). The backup commands report it asCould not resolve --output,--targetor<archive>, with the OS error.resolvePathPrefixSyncfrom@openclaw/fs-safewas not used: it follows every symlink, including the last one, which would change the paths--linkinstalls record.Two commands already had their own fix of this kind: the
infer audio/infer video--filepath (#192718) and thebackup verify/backup restorearchive path (#197688). This PR moves both to the shared resolver. It keeps #192718's rejection of a missing folder before..and of a trailing/or/.. All three backup paths (--output,--target,<archive>) go throughresolveBackupArchivePath, so they resolve the same way.Accepted edge cases, not handled:
plugins.load.paths, workspace dirs and so on) keepresolveUserPath. Changing them would change how existing configs load after an update, so this PR covers only paths typed for a command...(locked/..) still folds as text, as before. The OS would refuse it.Evidence
Live CLI runs with made-up plugins and an empty config in a temp folder, isolated HOME and state dir, on macOS, built from this branch and from
main(02dc1855e2d1for the plugin and diagnostics rows,b58996d69286for the backup rows). Setup:selected -> ../physical/nested, withphysical/plugin-b(idplugin-real) and a lexical neighbor./plugin-b(idplugin-decoy).mainplugins install ./selected/../plugin-bInstalled plugin: plugin-decoyInstalled plugin: plugin-realplugins install --link ./selected/../plugin-link(physical/plugin-link -> plugin-b)<root>/cwd/plugin-link(the neighbor link)<root>/physical/plugin-link(the link kept as typed)gateway diagnostics export --output selected/../bundle.zip<root>/cwd/bundle.zip<root>/physical/bundle.zipbackup create --output selected/../backup.tar.gzCreated <root>/cwd/backup.tar.gzCreated <root>/physical/backup.tar.gzbackup restore <archive> --target selected/../restored"targetPath": "<root>/cwd/restored""targetPath": "<root>/physical/restored"Tests:
mainand pass here: diagnostics export (1), plugin install with and without--link(2, the--linkrow through the linked validate-in-place install), localgit:install source (1),backup create --output(1),backup restore --target(1), and thePlugin path not foundmessage for a missing folder before..(1). The resolver contract inhome-dir.test.ts(symlink before.., final link kept, no..unchanged, missing or file segment before..throws) runs only with the resolver.infer audio transcribe --filerefusesmissing/../memo.wav,link/../memo.wav/andlink/../memo.wav/.before any transcription while a decoymemo.wavsits at the lexical spot (3, as onmain).capability-cli(121, including the fix: media inference reads the wrong file through symlink parents #192718 audio/video symlink case),agents.identity,templatesproject/reader/build/CLI,plugin-install-plan,dev-source-root,git-install,plugins-install-preflight,diagnostic-support-export,home-dir, and the 31backupcommand andbackup-createtest files (including fix(backup): verify and restore select the wrong archive after symlink/.. #197688's case, which expects the archive path the filesystem opened).tsgo(core and the touched test configs),oxlintandoxfmtare clean on the changed files.