Skip to content

fix(cli): keep backup create --to guard remedy in --json error output - #199763

Merged
obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/backup-create-to-guard-remedy-428
Nov 15, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/backup-create-to-guard-remedy-428

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw backup create --namespace x without --to correctly prints the remedy in text mode, but adding --json hides it from stderr: the stdout envelope carries the message, yet stderr only shows the generic [openclaw] The CLI command failed. and For help, run openclaw doctor. lines. This change routes the guard through the canonical expected-error owner so the remedy reaches stderr in both channels.

Why This Change Was Made

Reuse the established expected-error path for the existing missing-target guard. Its predicate and message remain unchanged:

--namespace, --claim-namespace, and retention flags require --to <location>.

The guard still runs before archive-path preparation, lifecycle custody, archive creation or any offsite work. There is no new formatter, flag, default, retention policy or message text. The additional internal pre-migration caller was inspected: it passes only output/verify options, so it cannot enter this guard.

Evidence

Fresh host source CLI comparison uses isolated HOME/config/state/TMPDIR and no Gateway. It exercises backup create --namespace x, backup create --keep-daily 3, and backup create --claim-namespace, each with and without --json, on base and candidate. No --to, --output or --dry-run was added to these operator commands.

  • Main JSON stderr shows the generic failure/Doctor hint; candidate JSON stderr shows the existing remedy.
  • JSON stdout envelopes, text stdout/stderr and exit code 1 remain byte-identical after normalizing isolated profile names.
  • Archive inventories stay empty before and after every guard invocation in the CLI cwd and isolated HOME/TMPDIR.
  • Focused backup tests: base 1 intended ExpectedCliError identity failure / 17 passes; candidate 18/18 passes. Commands test typecheck leaf and scoped lint/format checks pass. Full build/packed-entry receipts and exact-head hosted gates are linked in proof comments.

Production +4/-1; tests +6/-7 (net -1), no allocation file. The contributor's original human commit and implementation are retained without additional source/test edits.

Two-way door: a revert restores generic JSON stderr without changing stored state. Blast radius: missing---to preflight reporting for backup create; archive contents, successful backups, retention, migration and upload behavior are unchanged. The separate sibling guards in register.backup.ts are not part of this change.

Proof receipts: #199763 (comment)

@clawsweeper

clawsweeper Bot commented Nov 15, 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 commands Command implementations size: XS labels Nov 15, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR preserves the missing --to remedy on stderr when backup create rejects destination-specific flags in JSON mode.

Example: Run openclaw backup create --namespace x --json without --to.

  • Before: Stderr prints a generic command failure and Doctor hint.
  • After: Stderr prints: --namespace, --claim-namespace, and retention flags require --to <location>.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A small, complete repair with direct CLI comparisons, a fail-before/pass-after regression, and no identified correctness or security defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The exact-head receipt exercises real backup create commands through the source CLI on isolated macOS profiles, covers all three invalid option forms in text and JSON modes, and records the corrected stderr with unchanged stdout and exits; inspected screenshots belong to the historical storage feature and were not counted as proof of this fix.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Operators using JSON mode receive an unrelated Doctor hint on stderr instead of the existing missing-destination remedy.
Reason: This restores actionable diagnostics through an established contract without changing validation policy or backup behavior.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI diagnostic bug with a focused change and sufficient real CLI proof; no actionable defects were found, and required CI is still running.

Priority: P3
Reviewed head: 4bd3a320436a61622bee42cd5f1da867cc81ab2d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The backup command validates parsed CLI options before archive preparation; the shared CLI error owner then renders human diagnostics and the JSON failure envelope.

flowchart TD
  A[Backup CLI options] --> B[Backup create preflight]
  B --> C[Expected CLI error]
  C --> D[Shared failure renderer]
  D --> E[Remedy on stderr]
  D --> F[JSON envelope on stdout]
Loading

Technical review

Best possible solution:

Merge the existing focused conversion to the canonical expected-error owner once required CI passes.

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

Current-main source establishes the plain-error path, and the supplied base/head CLI receipt reproduces the generic stderr and verifies the correction; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch fixes classification at the existing validation owner, preserving the shared renderer, accepted inputs, message, and output envelope without adding machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Missing-destination validation keeps the original intent (37ffe3c: Storage-location support requires destination-specific namespace and retention options to have --to.)
  • Expected CLI error classification keeps the original intent (bc097bf: Preserve specific operator guidance using a dependency-light expected-error owner while retaining parsing and JSON contracts.)
  • Existing volatile-file JSON regression keeps the original intent (694ca50e9775f2d31d77471788cd91566b6610: The provenance identifies a runtime-state revert; the patch retains the existing archive and JSON assertions while adding the missing-target error contract.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 37ffe3c adds src/commands/backup.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 37ffe3ce94e2; files: src/commands/backup.ts)
  • Jerome: Raw commit bc097bf adds src/cli/expected-cli-error.ts:28 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bc097bf6404f; files: src/cli/expected-cli-error.ts)

PR surface

Source +3, Tests -1. Total +2 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 6 7 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 10 8 +2

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P3: This improves an advanced CLI validation diagnostic; JSON stdout already contains the remedy and backup execution remains safely rejected.
  • 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-11-15T21:21:06.702Z sha 4bd3a32 :: needs maintainer review before merge. :: none

Reviewed November 15, 2026, 4:55 PM ET / 21:55 UTC (Revision 2).

@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Proof for unchanged contributor head 4bd3a320436a61622bee42cd5f1da867cc81ab2d, against base/main 07ed3bfd1927e1410e36aa47cbc1fa4664cdd9d2.

Real CLI comparison

Host macOS arm64, source tier through ocx src, isolated HOME/config/state/TMPDIR and profile, no Gateway. Checked the real register.backup.ts forms before running these three inputs, each in JSON and text mode on both builds:

backup create --namespace x
backup create --keep-daily 3
backup create --claim-namespace

No --to, --output or --dry-run was added. All six invocations on each build exit 1.

main --json stderr:
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw --profile <isolated> doctor`.

candidate --json stderr:
--namespace, --claim-namespace, and retention flags require --to <location>.

Controls passed for all three inputs:

  • JSON stdout bytes (the existing ok:false, error.type:"cli_error", and existing error.message envelope) are identical.
  • Text stdout/stderr bytes and exit code 1 are identical.
  • Candidate JSON stderr equals the existing text remedy, including its newline.
  • Before and after each invocation, archive inventories in the actual CLI cwd and isolated HOME/TMPDIR remain empty. No backup archive is created. The guard also precedes archive-path preparation, custody acquisition and archive creation in the inspected control flow.

Profile names are deliberately different; only those names and ocx's own preparation diagnostics are normalized/separated. No product output is suppressed.

Checks and scope

  • Host vitest-source: copied regression on base gives 1 intended ExpectedCliError identity failure / 17 passes; candidate backup.test.ts passes 18/18. No source/test edits were needed after adopting the contributor's commit.
  • Host commands test typecheck leaf: scripts/run-tsgo.mts -p test/tsconfig/tsconfig.core.test.commands.json --noEmit, exit 0. Scoped oxlint and formatting check pass.
  • Host full: ocx build --dts passes on this exact head. Canonical tarball integrity/import checks pass; extracted packed entry prints OpenClaw 2026.11.3 (4bd3a32), exit 0. Packed smoke uses unchanged external dependencies from the checkout; no fresh-install or upload claim.
  • LSP references also identified the internal pre-migration caller. It supplies only output/verify options and cannot satisfy this guard. No migration, retention, archive or offsite behavior was changed or exercised by the negative CLI cases.
  • Host eligibility: only src/commands/backup.ts and backup.test.ts differ. No manifest, lockfile, workspace, script, patch or hook inputs changed. Source preparation was an ocx cache hit. Worktrunk hooks were skipped and commit/push hooks disabled.

Production +4/-1; tests +6/-7 (net -1), no allocation file, no new message text. The sole original human SunnyShu commit remains intact. Small logs and source/control harnesses are retained under the task's proofs/199763/ directory.

@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 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-environment Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 15, 2026
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Final unchanged contributor head: 4bd3a320436a61622bee42cd5f1da867cc81ab2d.

Task runtime state was removed; ocx scratch, worktree and temporary refs are being removed. The local branch and small proof receipts/harnesses remain available.

@obviyus
obviyus merged commit 5b080d2 into openclaw:main Nov 15, 2026
152 of 154 checks passed
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Landed in 5b080d2. Thanks @SunnyShu0925.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…openclaw#199763)

fix(cli): report backup create remote-flag errors through the expected-error path

`openclaw backup create --json` with `--namespace`, `--claim-namespace` or a `--keep-*` retention flag and no `--to` threw a plain error, so `--json` stderr showed the generic failure plus the Doctor hint instead of the existing "--namespace, --claim-namespace, and retention flags require --to <location>." message. The check runs before any archive work and now uses the expected-error path with the same message. No new text.

Evidence: host, isolated state, no Gateway. Source CLI with --json and in text mode: `backup create --namespace x`, `backup create --keep-daily 3` and `backup create --claim-namespace`. Base prints the generic failure and Doctor hint, this change prints the existing message; JSON stdout, text output and exit 1 are identical, and no archive is written on either side. Vitest-source: one case fails on base, 18 pass here; typecheck, lint, full build, tarball validation and packed smoke pass. Receipts: openclaw#199763 (comment).

Thanks @SunnyShu0925.

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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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