Skip to content

fix(backup): preserve literal archive paths - #186746

Merged
obviyus merged 2 commits into
openclaw:mainfrom
Alix-007:alix/fix-backup-literal-paths-20261028
Oct 28, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
Alix-007:alix/fix-backup-literal-paths-20261028

Conversation

@Alix-007

@Alix-007 Alix-007 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Quoted backup archive paths and restore targets lose leading/trailing spaces, selecting a different physical file or directory. Creation can report success at the wrong filename; verification/restore cannot reopen a valid literal archive.

User Impact

Nonblank archive paths now preserve their exact spelling across create, verify and restore, including home-relative output directories. Optional blank output retains its timestamped default; required blank paths remain errors. Generic Git, SQLite and schedule repository selectors retain their separate trimming contract.

Why This Change Was Made

One archive-specific resolver checks blankness without replacing the value, expands the existing home prefix, then resolves the literal path. All archive lifecycle callers use it before their existing publication, containment, capacity, tar validation, empty-target and extraction checks. No format, policy, config or migration change.

Evidence

#186746 (comment)

Normal-built public CLI on Linux Node 24.22.1, pinned main 7cbbb2548c8b900b211356ca9bd53e42008eede0 versus contributor product head 2261eda8d533f93679b4dff06b7f89d10e88444b: main twice and candidate twice, 44 real CLI calls. Final head 740bf9e0700e198cbae18cbe463d83f73f3c5fad only consolidates tests; production is unchanged from that measured product head.

  • Main writes trimmed leading/trailing-space filenames, cannot verify/restore independently renamed trailing-space archives, restores to the trimmed target, and misses the selected home-relative directory. Candidate honors every literal selection in both repeats.
  • Independent stat of exact/trimmed names, extracted manifest parsing and original config-byte readback confirm actual effects, not just success status. Ordinary create/verify/restore, optional blank output and required blank target controls retain their contracts.
  • Four focused owner suites: 83 passed, 1 existing platform skip, 29.43s. Scoped lint and repository formatter parity pass. Committed restore regression fails on pinned main for the intended missing-archive error (1 failed, 18 unselected; 10.85s).
  • Consolidated duplicate resolver setup into one table retaining archive-literal versus repository-trimming assertions. Production +15, tests −6, docs +3 versus merge base. No test-budget baseline change; contributor's +21 test-line growth eliminated.
  • Only synthetic config/task paths were used in secretless Docker. Native Windows/macOS, remote SSH/offsite operations, concurrent replacement, and released-package upgrades are not claimed.

Merge Danger

Two-way code door: revert restores prior selection behavior without changing the archive format. Reverting does not rename archives or restored directories already created with literal whitespace; callers must continue quoting their actual paths. Blast radius is archive create/verify/restore path selection; existing filesystem safety and generic repository-path policy remain unchanged.

@clawsweeper

clawsweeper Bot commented Oct 28, 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 docs Improvements or additions to documentation commands Command implementations size: S labels Oct 28, 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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserves leading and trailing whitespace in nonblank backup archive paths and restore destinations.

Example: Run backup create with --output 'selected.tar.gz ' --verify.

  • Before: Creation succeeds at selected.tar.gz, silently dropping the selected trailing space.
  • After: Creation and verification use the exact filename selected.tar.gz followed by a space.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused complete fix with shipped-CLI proof, preserved safety checks, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The linked collaborator report exercises normally built backup create, verify, and restore on Linux Node 24.22.1 before and after the production change, confirms exact paths and restored config bytes, and includes ordinary and blank-input controls; final-head differences are test-only.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Quoted archive names and restore destinations can select different physical paths because leading or trailing whitespace is removed.
Reason: Exact filesystem selection is concrete user value, and the collaborator's repair and CLI verification support the narrow archive-specific correction.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current archive-path selection bug with a focused change and relevant CLI proof; no actionable defects were found, and exact-head CI remains pending.

Priority: P2
Reviewed head: 740bf9e0700e198cbae18cbe463d83f73f3c5fad

Before merge

None.

Findings

None.

Agent review details

How this fits together

Backup CLI arguments flow through shared path resolution into archive publication, verification, and staging restore, producing archives or restored files and human-readable or JSON reports.

flowchart TD
  A[Backup CLI arguments] --> B[Archive path resolver]
  B --> C[Archive creation]
  B --> D[Archive verification]
  B --> E[Staging restore]
  C --> F[Filesystem artifacts]
  D --> G[CLI reports]
  E --> F
  F --> G
Loading

Technical review

Best possible solution:

Land the shared archive-path correction once the existing exact-head checks pass.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly shows argument trimming, and the supplied built-CLI comparison demonstrates the wrong filesystem selections; this read-only review ran no target code.

Is this the best way to solve the issue?

The smallest complete fix separates archive literal selection from repository trimming in the existing shared owner and updates every archive lifecycle caller.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d5f7d57eff50.

Provenance checked

  • Required backup path normalization changes intended behavior with a stated reason (68b4aab: Centralize duplicated required-path handling without changing existing trimming, home expansion, or errors.)
  • Archive output selection changes intended behavior with a stated reason (unknown: Extraction commit 3ba6491 already carried trimming; scoped git log -S and --follow encountered unavailable older blobs, and commit-to-PR lookup returned no linked PR.)
  • Archive verification and restore preparation keeps the original intent (e69a973: Verify archives before extracting into fresh staging directories, preserving containment and cleanup guarantees.)
  • Terminal-safe backup reporting keeps the original intent (b307533: Escape terminal controls in human reports while retaining original path, JSON, and restored payload values.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 68b4aab adds src/commands/backup-shared.ts:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 68b4aab8b389; files: src/commands/backup-shared.ts)
  • Peter Steinberger: Raw commit e69a973 adds src/commands/backup-restore.ts:51 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e69a973bfb74; files: src/commands/backup-restore.ts)
  • Alix-007: Raw commit b307533 adds src/commands/backup-restore.test.ts:125 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b307533754a1; files: src/commands/backup-restore.test.ts)

PR surface

Source +15, Tests -6, Docs +3. Total +12 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 24 9 +15
Tests 3 20 26 -6
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 47 35 +12

Review metrics

Metric Value Why it matters
Production versus test growth Production +15 net lines; tests −6 net lines One shared archive resolver replaces trimming at all three lifecycle boundaries, while existing command regressions gain literal-path coverage without new scaffolding.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Whitespace-containing archive selections can silently target a different filename or prevent verification and restore; the affected operator workflow has limited scope.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • 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-10-28T12:40:02.870Z sha 2261eda :: needs maintainer review before merge. :: none

Reviewed October 28, 2026, 10:21 AM ET / 14:21 UTC (Revision 2).

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Node 24 built-CLI before/after proof

Pinned main 7cbbb2548c8b900b211356ca9bd53e42008eede0 versus contributor product head 2261eda8d533f93679b4dff06b7f89d10e88444b. Both normal pnpm build outputs ran through node openclaw.mjs backup ... inside secretless Linux Docker, Node 24.22.1, with isolated synthetic HOME/config/state. Two independent fixture roots per version, 11 real CLI calls each: 44 calls total. No path owner, archive writer, verification or extraction mocks.

Actual operation, repeated twice per version Main Candidate
create --only-config --output 'selected.tar.gz ' --verify --json Exit 0 but literal filename absent, trimmed filename present Exit 0; literal present, trimmed absent
Verify independently copied valid archive named renamed.tar.gz Exit 1 Exit 0
Restore that independently renamed archive Exit 1; no restored tree Exit 0; original config bytes read back from manifest-declared payload
Restore ordinary archive into selected-restored Exit 0 but creates trimmed destination Exit 0; exact destination contains original config, trimmed destination absent
Create into existing ~/archive directory Exact directory remains empty; creates trimmed-name archive outside it Exactly one verified archive inside the selected directory; trimmed name absent
Create relative leading-space filename ' leading.tar.gz' Writes trimmed name Writes exact leading-space name only
Ordinary create → verify → restore All exit 0; manifest and original config bytes read back Same
Optional blank output Exit 0; timestamped default in task cwd Same
Required blank restore target Exit 1 Same

Readback independently stats literal and trimmed names, walks actual restored trees, parses the extracted manifest.json, and compares payload bytes with the input config. Create also uses real --verify. Only synthetic config is archived; no live Gateway, credentials, model or channel is involved. Native Windows/macOS, remote SSH, offsite backups, and released-package upgrades are not claimed.

The repair only consolidates the two existing resolver suites into one shared contract table (blank rejection, relative/absolute selection, effective-home expansion), retaining repository trimming versus archive literal semantics and the stronger real archive command regressions. No production change, archive-format change, baseline adjustment, or safety-policy change was needed.

Focused validation: four real-owner suites 83 passed, 1 existing platform skip, 29.43 seconds; scoped lint reports 0 warnings/errors, and repository oxfmt/Bun parity check passes. Test consolidation reduces the PR test delta from +21 to −6 lines (no budget/baseline change); production stays +15 and docs +3 against the merge base.

Discriminating committed restore regression copied onto pinned main: 1 intended failure, 18 unselected, 10.85 seconds: Archive does not exist after the archive selector trims the trailing space; the same regression passes in the candidate four-suite run.

Final head: 740bf9e0700e198cbae18cbe463d83f73f3c5fad; contributor commit retained, only test consolidation added. Built-CLI production inputs are identical to the measured contributor product head.

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@obviyus
obviyus merged commit e32d529 into openclaw:main Oct 28, 2026
125 of 126 checks passed
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Landed in e32d529. Thanks @Alix-007. Backup commands now keep archive and destination paths exactly as given.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for reviewing and merging this. Much appreciated!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
fix(backup): keep literal archive and destination paths in backup commands

backup create, verify and restore trimmed the archive and destination paths they were given, so a path that starts or ends with a space chose a different file or directory, or couldn't reopen the archive just written. The commands now use the path as given. Home expansion, the default output when none is given, and the rejection of blank targets are unchanged.

Evidence: built CLI on Node 24.22.1 (44 real calls). On main the trimmed archive or destination name was used, or the literal archive couldn't be reopened (twice); with this change every given path was kept (twice), confirmed by separate filesystem, manifest and config-byte readback. Ordinary round trips, home expansion, the blank-output default and blank-target rejection behave the same on both refs. Details: openclaw#186746 (comment).

Thanks @Alix-007.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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