Repository navigation
fix(backup): verify and restore select the wrong archive after symlink/.. - #197688
Conversation
|
🦞👀 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 changesPreserves POSIX parent components in input archive paths so verification and restore follow filesystem symlink resolution. Example: With /backups/alias pointing to physical/child, restore /backups/alias/../archive.tar.gz.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current wrong-archive selection bug with a focused change and convincing CLI evidence; no actionable findings remain, and exact-head CI is pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe backup CLI passes archive arguments to the shared preparation boundary, which verifies the selected archive and supplies the same pathname to staging extraction. flowchart TD
A[Backup CLI] --> B[Prepare archive input]
B --> C[Filesystem pathname resolution]
C --> D[Archive verification]
D --> E[Verification report]
D --> F[Restore to fresh staging]
Technical reviewBest possible solution: Land the focused repair at the shared archive input boundary once required CI passes. Do we have a high-confidence way to reproduce the issue? Current-main source shows lexical parent collapse before filesystem access, and the linked report and collaborator CLI runs demonstrate wrong-archive selection; this review executed no target code. Is this the best way to solve the issue? The patch restores filesystem pathname semantics at the existing shared preparation owner without introducing another resolver module or changing archive contents or restore-target policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 924e23efe613. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +8, Tests 0. Total +8 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: No label 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 12, 2026, 6:10 AM ET / 11:10 UTC (Revision 2). |
|
Proof for head 57ee6d8 (main 4ea8ace merged in, no force-push). Both runs used the built CLI ( Setup: two real archives made with
Tests: the regression is folded into the existing POSIX restore case, and a redundant multi-line call was collapsed, so net test lines are 0. That case fails on main and passes here. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…k/.. (#197688) fix(backup): resolve archive paths through symlinks before parent segments On Linux and macOS, openclaw backup verify and backup restore collapsed a path like link/../archive.tar.gz as text before the system followed the symlink, so they read a different archive than the shell would, and restore staged the wrong backup's config. Outside Windows the parent segments are now kept, so the system resolves them after following the symlink. Windows is unchanged, and no backup format, storage, retention or restore policy changes. No text changes. Evidence: the real CLI in a secretless node:24.22.1 container with two config-only backups holding different markers and a directory symlink that makes link/../archive.tar.gz resolve to the second archive. On main, verify and restore through that path (absolute and relative) picked the first archive; with this change they pick the same archive the shell reads. A plain absolute path, a relative path without parent segments, a parent segment without a symlink, a missing archive and a non-empty restore target behave the same on both, and live config stays untouched. The folded POSIX restore test fails on main, at net 0 test lines. Details: openclaw/openclaw#197688. Closes #197685. Thanks @Malpin07. Co-authored-by: Ayaan Zaidi <[email protected]>
…k/.. (openclaw#197688) fix(backup): resolve archive paths through symlinks before parent segments On Linux and macOS, openclaw backup verify and backup restore collapsed a path like link/../archive.tar.gz as text before the system followed the symlink, so they read a different archive than the shell would, and restore staged the wrong backup's config. Outside Windows the parent segments are now kept, so the system resolves them after following the symlink. Windows is unchanged, and no backup format, storage, retention or restore policy changes. No text changes. Evidence: the real CLI in a secretless node:24.22.1 container with two config-only backups holding different markers and a directory symlink that makes link/../archive.tar.gz resolve to the second archive. On main, verify and restore through that path (absolute and relative) picked the first archive; with this change they pick the same archive the shell reads. A plain absolute path, a relative path without parent segments, a parent segment without a symlink, a missing archive and a non-empty restore target behave the same on both, and live config stays untouched. The folded POSIX restore test fails on main, at net 0 test lines. Details: openclaw#197688. Closes openclaw#197685. Thanks @Malpin07. Co-authored-by: Ayaan Zaidi <[email protected]>
…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`.
…der is followed by `..` (#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 #192718) and the templates project commands through it. Config-stored paths keep resolveUserPath. Closes #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 (#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
…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
…k/.. (openclaw#197688) fix(backup): resolve archive paths through symlinks before parent segments On Linux and macOS, openclaw backup verify and backup restore collapsed a path like link/../archive.tar.gz as text before the system followed the symlink, so they read a different archive than the shell would, and restore staged the wrong backup's config. Outside Windows the parent segments are now kept, so the system resolves them after following the symlink. Windows is unchanged, and no backup format, storage, retention or restore policy changes. No text changes. Evidence: the real CLI in a secretless node:24.22.1 container with two config-only backups holding different markers and a directory symlink that makes link/../archive.tar.gz resolve to the second archive. On main, verify and restore through that path (absolute and relative) picked the first archive; with this change they pick the same archive the shell reads. A plain absolute path, a relative path without parent segments, a parent segment without a symlink, a missing archive and a non-empty restore target behave the same on both, and live config stays untouched. The folded POSIX restore test fails on main, at net 0 test lines. Details: openclaw#197688. Closes openclaw#197685. Thanks @Malpin07. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit c4bf368) Source-x: c4bf368 Backport scope: In backup-verify.ts prepareBackupArchive preserve POSIX filesystem parent semantics with home expansion; leave Windows and archive validation unchanged. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit e9c33692959acaa09114e8aaa190a180e594d817)
Closes #197685
What Problem This Solves
Fixes
backup verifyandbackup restoreselecting a different archive when a POSIX input path contains a directory symlink followed by...User Impact
Both commands read the archive selected by the filesystem, and missing parent directories are rejected instead of silently selecting a same-named archive. For affected inputs, the reported absolute
archivePathretains the parent components.Why This Change Was Made
Preserve those POSIX components at the existing shared archive input boundary, so verification and extraction use the same path. Other input spelling and Windows resolution retain their current behavior. The repair is confined to existing archive input handling; archive contents and restore-target checks keep their existing owners.
Evidence
Real source-built CLI runs on WSL2 Ubuntu 26.04 / Node 26.12.1, with two valid archives generated by
backup create --only-config. Their configurations contain differentmessages.responsePrefixmarkers. The linked issue includes the fixture and pre-fix output.4eb318d5f7f6fd6dealias/../archive.tar.gzalias/../archive.tar.gzmissing/../archive.tar.gzFinal run: 10 successful CLI calls and 2 expected rejections. Archive manifests, archive hashes, and restored configuration bytes were checked; all child processes exited and temporary state was removed.
Final CLI output excerpts (temporary prefix abbreviated)
backup verify "$fixture/alias/../archive.tar.gz" --json:{ "ok": true, "archivePath": "<temporary>/fixture/alias/../archive.tar.gz", "archiveRoot": "2026-11-12T18-17-37.269+08-00-openclaw-backup", "createdAt": "2026-11-12T10:17:37.269Z", "runtimeVersion": "2026.11.3", "assetCount": 1, "entryCount": 2, "symlinkCount": 0, "sqliteInventoryVerified": true }Actual restored configuration:
{"messages":{"responsePrefix":"RIGHT"}}backup restore "$fixture/missing/../archive.tar.gz" --target "$staging" --jsonexits 1:{ "ok": false, "error": { "type": "cli_error", "message": "Backup archive verification failed: <temporary>/fixture/missing/../archive.tar.gz. Archive does not exist. Check the path and run `openclaw backup verify <archive>` again." } }pnpm test src/commands/backup-restore.test.ts --maxWorkers=1: 20 tests, 20.6 s wall time (16.53 s Vitest). CI seconds are pending the first hosted run.git diff --checkpassed.pnpm buildpassed on both base (546.3 s) and final commit (417.9 s), with matching build metadata and clean source trees.Native Windows/macOS execution, the full repository test suite, and the local ClawSweeper/shared autoreview CLI were not run. Production net change: +8 lines; tests: +47, reusing the existing fixture and adding no new helper module or dependency.