Repository navigation
fix(database): use canonical CLI JSON failures - #183393
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 changesDatabase operational failures reuse the canonical CLI JSON failure envelope. Example: Run openclaw database ownership claim --manager supervisor --json without external-supervisor mode.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a documented CLI contract violation with a focused change; no actionable defects were found, and exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDatabase command handlers catch operational errors and send them through a shared writer that selects JSON stdout or human stderr and exits with status 1. flowchart TD
A[Database CLI invocation] --> B[Database operation]
B --> C[Shared database error writer]
C --> D[Canonical JSON formatter]
D --> E[JSON stdout and exit 1]
C --> F[Human stderr and exit 1]
Technical reviewBest possible solution: Merge the existing shared-writer fix once the normal exact-head checks pass. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows the incorrect string-valued error, and the supplied built-CLI comparison records the corresponding failure; this read-only review ran no target code. Is this the best way to solve the issue? This is the smallest complete fix: retain the existing database error boundary, delegate JSON formatting to its canonical owner, and strengthen the existing process regression. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 47a88380810f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +3. Total +3 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label 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 October 25, 2026, 8:02 PM ET / October 26, 2026, 00:02 UTC (Revision 2). |
Preserve the canonical failure renderer and existing live-owner regression checks while integrating the current database command changes. Co-authored-by: Leon-SK668 <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
|
Thanks for reviewing and landing this, @steipete! I appreciate the integration work; database scripts can now read failures through the shared CLI JSON contract. |
) Co-authored-by: Leon-SK668 <[email protected]>
Co-authored-by: Leon-SK668 <[email protected]> (cherry picked from commit e4074cb) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 6232b6321b23bf5eb8177571782c1856c9aed715)
What Problem This Solves
Database commands emit a string-valued
erroron operational failures, so scripts cannot use the documented CLI-wide JSON failure contract.User Impact
Failed JSON-mode database commands return
ok: falseanderror.type: "cli_error"with exit status 1. Successful payloads, human diagnostics, and ownership/custody checks retain their existing behavior.Why This Change Was Made
The existing shared database error writer now uses
formatCliJsonFailure, the canonical owner of CLI failure output. No second renderer, new error boundary, schema change, or config option is introduced.Original fix and native proof by @Leon-SK668. Co-authored-by: Leon-SK668 [email protected]
Evidence
Current-main regression: the two Gateway/embedded-agent refusal cases fail with the old string-valued error; both successful claim controls pass. With the fix, the same cases assert the canonical envelope and retain database/WAL/SHM preservation and subsequent owner-write checks. The import-boundary test also verifies that database registration does not eagerly load operation/schema runtimes.
Local commands:
TMPDIR=/private/tmp/oc-ct-cliinput OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/cli/database-ownership.process.test.ts src/cli/program/register.database.import-boundary.test.ts --maxWorkers=1; targeted oxlint, oxfmt, andgit diff --check. Baseline6d808362dd8a4853317fafef764b92ec2dac21bc: the intended two refusal cases fail; two claim controls and the import-boundary test pass (133.53s wrapper wall time). Integrated candidate: all five tests pass (199.55s wrapper wall time, ownership suite 163.30s including cold compilation; test bodies 8.9–12.9s each). This extends the existing process fixture because in-process helper tests would miss CLI output/exit behavior and live ownership preservation. Targeted type-aware oxlint, oxfmt, and diff check pass. Codex autoreview is scoped-clean with no actionable P0–P2 findings. Changed-file checks passed the structural/boundary ratchets, then refused local typechecking because compiler dependencies resolve to the shared worktree installation. Their later full-tree dead-export scan reported unchanged main exportcreateScenarioCommandEnvironmentin the Telegram e2e script; broad scans were stopped to respect local scope. Exact-head CI is green forf8a046ad8961d281275d770b5bf4ae59b3eea864: run 40247047096, including the CI gate and actual type/lint checks. The unrelated local dead-export finding did not fail this CI run. Final-head ClawSweeper review is clean (2026-10-26 00:02 UTC).Contributor native proof on Linux/Node 24.22.1 used the same built-CLI driver on base
f9ddc22f7a8be8d73fd88b1c24f5bf0d9348ffddand candidate216551373cf1c36f7f5512d0140b448d1c931417, with separate temporary home/state/config. Eight process cases covered canonical ownership, restore-path and preservation-locator refusals; byte-identical human ownership diagnostics; fresh/unmodified ownership status; and a legitimate external-manager claim with independent SQLite readback. For example, a claim without external-supervisor mode exited 1 on both: base returned{"error":"Claiming external shared-state ownership requires OPENCLAW_SUPERVISOR_MODE=external."}, candidate returned the same message inside the canonical envelope. Driver SHA-256:4a141df00c62b4cc5793eec7db7fa1c5e9a222ac365fbfef92c4ef874963fa5e.No fresh built-CLI live run was performed after integration on this loaded Mac; the contributor proof is retained and attributed, and the current-main process regression supplies the new boundary proof. Actual database port/restore, PostgreSQL, production services, and cross-platform behavior were not live-tested; this patch only changes failure rendering.
Production +3/-3 (net 0); tests +5/-2 (net +3). Simplification removes the private JSON envelope while retaining the existing error owner and process fixture.