Skip to content

fix(backup): diagnose invalid archive inputs - #124510

Merged
steipete merged 1 commit into
mainfrom
steipete/backup-verify-preflight
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/backup-verify-preflight

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators running openclaw backup verify received raw Node filesystem errors for missing or directory inputs, while a non-tar garbage file was incorrectly reported as an empty backup. These diagnostics are especially risky immediately before a restore because they point the operator at the wrong failure.

The original behavior came from #40163: archive listing discarded tar's recoverable TAR_BAD_ARCHIVE warning and then treated the resulting zero-entry list as proof of emptiness.

Why This Change Was Made

verifyBackupArchive now owns the archive preflight and wraps every verification failure with the resolved archive path, so direct verification, backup restore, and backup create --verify all share the same diagnostics. Archive listing preserves TAR_BAD_ARCHIVE evidence and reports zero-entry/unrecognized inputs as an invalid OpenClaw backup. A legal zero-entry tar and short garbage produce the same dependency signal, and neither can be a valid OpenClaw backup because the manifest is mandatory.

The bounded filesystem-path sweep also fixes raw missing-path errors shared by SQLite snapshot verify/restore and centralizes regular-file validation for config set --batch-file and config patch --file. Existing correct backup Git initialization, SQLite listing, plugin path installation, and normal media validation paths were left unchanged.

Production LOC: +86/-30 (net +56). Tests: +101/-1. The production growth is the operator-facing classification and recovery guidance at three existing owner boundaries; no compatibility layer, fallback, new public API, or new helper surface was added, and the shared config reader deletes duplicate caller-side error translation.

User Impact

Operators now see the archive path, the actual problem, and a concrete recovery step. Exit codes and successful text/JSON output are unchanged.

Examples after this change:

Backup archive verification failed: <scratch>/nope.tar.gz. Archive does not exist. Check the path and run `openclaw backup verify <archive>` again.  exit 1
Backup archive verification failed: <scratch>. Archive must be a regular file. Choose a backup archive created by `openclaw backup create` and try again.  exit 1
Backup archive verification failed: <scratch>/bad-archive.tar.gz. Archive is not a valid OpenClaw backup. Unrecognized archive format. Choose another archive or create a new one with `openclaw backup create`.  exit 1

Evidence

Before, on macOS at 063ce57caf2:

ENOENT: no such file or directory, stat '/tmp/nope.tar.gz'  exit 1
EISDIR: illegal operation on a directory, read             exit 1
Backup archive is empty.                                   exit 1

After, on the exact synced patch in Blacksmith Testbox tbx_01m04swtd9nvpctnw0n8me38fd:

  • all three repros produced the messages above at exit 1;
  • backup create --verify created a real scratch-state archive;
  • a separate backup verify passed with 1 asset and 3 archive entries;
  • full pnpm build passed;
  • node scripts/check-changed.mjs passed;
  • node scripts/run-vitest.mjs src/commands/backup-verify.test.ts src/commands/backup-sqlite.test.ts src/cli/config-set-input.test.ts src/cli/config-cli.test.ts passed: 242 tests, 1 skipped;
  • autoreview reported no accepted/actionable findings.

Remote proof: https://github.com/openclaw/openclaw/actions/runs/31935737819

AI-assisted: yes. The implementation and observed behavior were reviewed and understood.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 16, 2026 08:29
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 4:36 AM ET / 08:36 UTC.

ClawSweeper review

What this changes

The PR replaces misleading backup and CLI file-input errors with actionable validation diagnostics for invalid paths and archives.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer landing: the active maintainer PR repairs a source-backed diagnostic bug at the shared backup and file-input boundaries, with no blocking patch finding found.

Priority: P2
Reviewed head: 87ae401ab30652b6b596641bd4a2186de8d678a3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair is source-backed, focused, and accompanied by command-boundary tests plus reported Testbox validation.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR includes an after-fix Blacksmith Testbox terminal report in its body; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR includes an after-fix Blacksmith Testbox terminal report in its body; the external-contributor proof gate does not apply.
Evidence reviewed 6 items Current-main defect: Current main discards tar warnings during archive listing and then reports a zero-entry result as an empty backup; the PR preserves invalid-archive evidence before that classification.
Shared caller coverage: The verifier is used by the direct CLI command, restore flow, and create-with-verify flow; the PR keeps one preflight owner for all three.
Dependency contract: The PR directly invokes the locked tar dependency; inspected tar source wires onwarn and emits TAR_BAD_ARCHIVE when no valid entry is found. The repository lock pins tar 7.5.22.
Findings None None.
Security None None.

How this fits together

Backup commands validate archive inputs before verification, restore, and post-create checks; config commands validate JSON5 files before mutation. These paths turn operator-provided files into command results and exit statuses.

flowchart LR
  A[Operator file path] --> B[Backup or config command]
  B --> C[Shared input validation]
  C --> D[Verification or mutation]
  D --> E[Actionable result and exit status]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by 56 net lines; the extra validation and recovery text is concentrated in shared owner boundaries, and no net-neutral alternative was found without restoring duplicate caller-side translation.
  • Resolve merge risk (P1) - A fresh structured autoreview could not run in this read-only environment because its TruffleHog prerequisite is unavailable; run it from a prepared environment before merge.
  • Complete next step (P2) - This active maintainer PR already owns the repair; run exact-head checks and a fresh autoreview before landing rather than opening a separate repair job.
Agent review details

Security

None.

PR surface

Source +56, Tests +100. Total +156 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 86 30 +56
Tests 4 101 1 +100
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 187 31 +156

Review metrics

Metric Value Why it matters
Production vs tests production +86/-30 (net +56), tests +101/-1 The diagnostic repair grows shared owner-boundary code and adds focused command-level regression coverage.

Stored data model

Persistent data-model change detected: serialized state: src/commands/backup-verify.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain one archive preflight shared by verify, restore, and post-create verification, and keep regular-file validation centralized in the config input reader.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain one archive preflight shared by verify, restore, and post-create verification, and keep regular-file validation centralized in the config input reader.

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

Yes, from source: current main loses the tar invalid-archive warning and treats the resulting empty list as an empty backup; the PR body also supplies before/after CLI evidence.

Is this the best way to solve the issue?

Yes: the proposed preflight is at the shared verifier and config-reader owners, so direct verification, restore, post-create verification, and both config file modes do not need separate translations.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b097aaab2061.

Labels

Label changes:

  • add P2: The PR repairs operator-facing backup and CLI diagnostics with limited blast radius.
  • 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. Not applicable: This maintainer-authored PR includes an after-fix Blacksmith Testbox terminal report in its body; the external-contributor proof gate does not apply.

Label justifications:

  • P2: The PR repairs operator-facing backup and CLI diagnostics with limited blast radius.
  • 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. Not applicable: This maintainer-authored PR includes an after-fix Blacksmith Testbox terminal report in its body; the external-contributor proof gate does not apply.

Evidence

What I checked:

  • Current-main defect: Current main discards tar warnings during archive listing and then reports a zero-entry result as an empty backup; the PR preserves invalid-archive evidence before that classification. (src/commands/backup-verify.ts:70, b097aaab2061)
  • Shared caller coverage: The verifier is used by the direct CLI command, restore flow, and create-with-verify flow; the PR keeps one preflight owner for all three. (src/commands/backup-restore.ts:132, 87ae401ab306)
  • Dependency contract: The PR directly invokes the locked tar dependency; inspected tar source wires onwarn and emits TAR_BAD_ARCHIVE when no valid entry is found. The repository lock pins tar 7.5.22. (src/commands/backup-verify.ts:74, 87ae401ab306)
  • Behavioral regression tests: The added table-driven command-boundary test covers missing archives, directories, and non-tar input; companion tests cover shared config-file and SQLite-path diagnostics. (src/commands/backup-verify.test.ts:247, 87ae401ab306)
  • Feature provenance: Blame attributes the current archive listing and zero-entry classification to the current shallow-history boundary; the original backup feature merged as the linked local-backup CLI change. (src/commands/backup-verify.ts:70, 057f98359eb0)
  • Patch hygiene: The branch is clean and the reviewed diff has no whitespace errors. (src/commands/backup-verify.ts:549, 87ae401ab306)

Likely related people:

  • steipete: Current-main blame attributes the archive verifier, config file reader, and SQLite snapshot-resolution boundaries to the available history boundary authored by Peter Steinberger. (role: recent area contributor; confidence: medium; commits: 057f98359eb0; files: src/commands/backup-verify.ts, src/cli/config-set-input.ts, src/snapshot/local-repository.ts)
  • shichangs: Authored the merged local-backup CLI feature that established the verifier this repair updates. (role: backup feature author; confidence: high; commits: 0ecfd37b4465; files: src/commands/backup-verify.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run fresh autoreview in an environment with TruffleHog available before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit b990160 into main Aug 16, 2026
247 of 253 checks passed
@steipete
steipete deleted the steipete/backup-verify-preflight branch August 16, 2026 08:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

cli CLI command changes commands Command implementations maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant