Repository navigation
fix(cli): keep backup sqlite snapshot source remedies on JSON failures - #199760
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 changesClassifies three invalid SQLite snapshot source selections as expected CLI errors so JSON-mode stderr preserves their existing remedies. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main diagnostic defect with a minimal change and verified CLI evidence; no actionable findings remain, while exact-head CI is unfinished. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe backup CLI passes source options to the snapshot command, whose validation errors reach the shared CLI renderer for JSON stdout, stderr diagnostics, and exit handling. flowchart TD
A[Backup CLI arguments] --> B[SQLite snapshot command]
B --> C[Source validation]
C --> D[Expected CLI error]
D --> E[Shared failure renderer]
E --> F[JSON stdout and actionable stderr]
Technical reviewBest possible solution: Use the existing expected-error helper at the three source guards while retaining source-selection behavior and the consolidated regression cases. Do we have a high-confidence way to reproduce the issue? Current-main guards and the shared failure renderer establish the failure path; supplied CLI before/after output independently demonstrates it, with no target code executed during this review. Is this the best way to solve the issue? This is the smallest complete repair: classify the existing expected input failures at their producer and reuse the shared renderer without adding policy, state, or wrappers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 141765220338. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests -12. Total -11 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:
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 15, 2026, 4:52 PM ET / 21:52 UTC (Revision 2). |
|
Validated final head Real CLI observationsTier: source, host through These three commands were run once per side with For all three JSON failures, main stderr was: Candidate stderr instead contained the existing specific message:
All six invalid executions on each side exited 1, and none created a snapshot repository. Text-mode stdout/stderr and JSON stdout were byte-identical before and after. Only JSON stderr changed to the existing diagnostic. Identical JSON stdout SHA-256 on both sides:
Successful control
{"ok":true,"schemaVersion":1,"database":{"role":"global","basename":"openclaw.sqlite","userVersion":40},"artifactPath":"database.sqlite","artifactBytes":1400832,"artifactHashMatches":true,"snapshotCount":1}The artifact bytes were independently hashed and matched their respective manifests. The two private databases were initialized independently, so snapshot IDs/times and whole-database hashes were not treated as identical inputs. Regression and scope
Merge danger: reversible error-classification/test change. Blast radius: stderr presentation of the three local SQLite snapshot-source refusals. Full package and final scope
Hosted gates on the final head
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 90af47b. Thanks @SunnyShu0925. |
openclaw#199760) fix(cli): report backup sqlite create source errors through the expected-error path `openclaw backup sqlite create --json` threw plain errors when no snapshot source was given, when both `--global` and `--agent` were given, and when `--agent` was blank, so `--json` stderr showed the generic failure plus the Doctor hint instead of the existing message. The three checks run before any state is read and now use the expected-error path with the same messages. No new text. Evidence: host, isolated state, no Gateway. Source CLI with --json and in text mode: `backup sqlite create --repository <tmp>` with no source, with `--global --agent main`, and with `--agent ' '`. Base prints the generic failure and Doctor hint, this change prints the existing message; text output, JSON stdout and exit codes are identical, and a valid `--global` snapshot succeeds the same way on both. Vitest-source: three cases fail on base, 12 pass here; typecheck, full build and packed smoke pass. Receipts: openclaw#199760 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
openclaw backup sqlite createvalidates its snapshot source before touching any state, but all three guards inresolveSnapshotDatabasethrew a plainError. The shared CLI runner only preserves the message forExpectedCliError/ExitError, so in--jsonmode the actionable remedy was replaced on stderr by:Why This Change Was Made
The guards already carry the actionable remedy (
--globalor--agent <id>, non-blank--agent). Routing them through the existingthrowExpectedCliErrorhelper keeps that text on both output lanes, matching the remedy-preservation fixes already shipped for other CLI guards (#199562, #199573, #199608).Only the throw sites change: the three guards in
src/commands/backup-sqlite.tsnow raiseExpectedCliErrorwith byte-identical messages. No message text, exit code, JSON envelope shape, or validation ordering changes.User Impact
Scripts calling
backup sqlite create --jsonnow see the actual fix in stderr instead of a generic failure. Text-mode output, exit codes, and the JSON payload are unchanged.Evidence
Both arms built with
node --import ./scripts/tsx.mjs scripts/build-all.mts cliStartupand exercised through the shipped entry pointnode openclaw.mjs, each with its own scratchHOME/OPENCLAW_STATE_DIR.Arm identity (self-reported):
Before/after,
--jsonlane, stderr (Node security warning and log-append noise elided; identical on both arms):backup sqlite create --repository /tmp/snap --jsonThe CLI command failed./For help, run \openclaw doctor`.`Choose a SQLite snapshot source: --global or --agent <id>.backup sqlite create --global --agent main --repository /tmp/snap --jsonThe CLI command failed./For help, run \openclaw doctor`.`Choose exactly one SQLite snapshot source: --global or --agent <id>.backup sqlite create --agent " " --repository /tmp/snap --jsonThe CLI command failed./For help, run \openclaw doctor`.`--agent must not be blankInvariants across the three cells:
cmpreports stdout JSON payloads byte-identical between arms, text-lane stderr byte-identical, and every cell exits 1.Regression tests folded into the existing
backup-sqlite.test.tscases (net 0 test lines):Maintainer validation
Validated
8d225731b3c4249bca7d94fdf21fcbee213483f0: real CLI source-selection diagnostics, identical stdout/text/exit controls, successful global snapshots, regression, typecheck and packed-install receipts. The contributor production fix is unchanged. A compact four-case test table retains all messages and classifications while reducing test lines.Merge danger: reversible error-classification/test change. Blast radius: stderr presentation of the three local SQLite snapshot-source refusals.