Repository navigation
fix(backup): keep whitespace-suffixed git backup repository roots adoptable - #197974
wangmiao0668000666 wants to merge 1 commit into
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 real behavior proof before merge. What this changesPreserve meaningful trailing whitespace when validating a Git backup repository's root path. Example: Initialize a pre-created private repository at "/mnt/backups/openclaw " through initializeGitBackupRepository.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR contains a focused fix for a current backup repository validation bug, with no introduced correctness or security defect identified. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe backup subsystem receives repository paths, checks filesystem privacy and Git worktree identity, and supplies validated repositories to initialization, backup creation, verification, restore, and log operations. flowchart LR
A[Backup CLI] --> B[Required path resolver]
B --> C[Backup repository initializer]
C --> D[Private directory admission]
C --> E[Git root validation]
E --> F[Canonical filesystem comparison]
F --> G[Repository operations]
Technical reviewBest possible solution: Complete the literal-path repair through the existing CLI and snapshot owners in coordination with #195644. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows pathname loss before realpath, and the supplied regression trace reports the corresponding baseline failure; no target code was executed during this review. Is this the best way to solve the issue? Removing only Git's final LF is the smallest complete correction at assertGitRepository, but the stated CLI outcome also requires preserving the argument before it reaches that owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 20237d956bb5. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +13. Total +17 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. Review metrics
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 Reviewed November 12, 2026, 6:41 PM ET / 23:41 UTC. |
|
Closing in favor of #195644, which is the strictly broader repair for the same defect family and is already
Two things from this PR that are not in #195644 and may be worth porting there or tracking separately:
Evidence (base-red/head-green vitest output) remains in the PR body and the branch ( |
What Problem This Solves
openclaw backup git init --repository <path>verifies an adopted backup repository by comparinggit rev-parse --show-toplevelagainst the requested path. The sharedrequireGitCommandhelper trims the output, so a backup repository whose directory legitimately ends in whitespace (for example/mnt/backups/openclaw) had its meaningful trailing space stripped; the subsequentfs.realpaththen failed with ENOENT (or compared against a different directory) and initialization refused a valid operator-owned repository. The same root-cause shape was approved for the update path in #196654 and already shipped insrc/projects/project-checkout.ts.Precedent: #196654 (same root cause at the update-check call site; this PR covers the git-backup adoption check)
Why This Change Was Made
assertGitRepositoryinsrc/snapshot/git-backup.tsnow reads the top level through the existingexecuteGitCommand+requireGitCommandOutputowners and removes only Git's final LF record terminator (replace(/\n$/, "")), preserving filesystem characters in the repository path. The sharedrequireGitCommandhelper is intentionally untouched (many callers rely on its trimmed output for non-path values); only this path-typed call site changes. The probe a few lines below already used the untrimmedrunGitresult, so the two checks are now consistent.Production LOC is
+5/-1in one file.Classification:
behavior-completingUser Impact
Adopting a Git backup repository under a whitespace-suffixed directory now verifies and initializes correctly, including the follow-up
remote addand first commit. Ordinary repository paths are byte-for-byte unaffected. Creation of a not-yet-existing whitespace-suffixed directory remains owned by@openclaw/fs-safeand is out of scope for this in-repo fix (the regression test pre-creates the private root, which is also the supported adoption flow for existing directories).Evidence
Exact-head proof receipt
51820d5e6db476024435027d4ac4e51a58468bb1b5c4842d9fb0initializeGitBackupRepository→assertGitRepositoryinsrc/snapshot/git-backup.ts(CLI surface:backup git init --repository <path>)assertGitRepositoryatsrc/snapshot/git-backup.ts:162-171gitsubprocess end-to-end in the existingsrc/snapshot/git-backup-ownership.test.tsharness (the test initializes, configures identity, commits a file, and reads it back)repositoryfails withENOENT: no such file or directory, realpath '<tmp>/repository'(the trimmed path) thrown fromassertGitRepositorynote.txt, and reads back its contents — 10/10 tests passInspectable RED -> GREEN terminal trace
Vitest shard on the real runner (Node 24.22.1, docker
lexiflow-all):Verification
node scripts/run-vitest.mjs run src/snapshot/git-backup-ownership.test.ts --maxWorkers=1— 10/10 passed on exact head; RED reproduced on current main with only the new testopenclaw backup git initend-to-end via the packaged CLI against a live Gateway was not run on the proof host (kernel 3.10 blocks the Gateway runtime); the verified boundary is the realinitializeGitBackupRepositorypath with realgitand real filesystem, matching the proof style of the sibling snapshot/backup tests.Scope and risk
+5/-1(src/snapshot/git-backup.ts)+13(src/snapshot/git-backup-ownership.test.ts)executeGitCommand/requireGitCommandOutputowners and the approvedreplace(/\n$/, "")predicate from fix(update): preserve Git identity for whitespace-suffixed checkout paths #196654; the sharedrequireGitCommandsignature is unchangedMaintainer edits
Maintainer options
requireGitCommandhelper for every caller; rejected because non-path callers rely on the trimmed output (matches the fix(update): preserve Git identity for whitespace-suffixed checkout paths #196654 review direction of per-call-site, path-typed fixes).