Repository navigation
fix(cli): surface onboard recommendations blank --agent remedy in --json failures - #199523
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 changesClassify a blank onboarding recommendation agent selector as an expected CLI error so JSON-mode failures display the remedy on stderr. Example: Run openclaw onboard recommendations --agent " " --json.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current CLI diagnostic defect with a minimal change and convincing real-command proof; no actionable patch defects were found, while required CI remains incomplete. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe onboarding recommendations CLI passes the agent selector into a shared store factory; validation errors flow through the root CLI renderer to JSON stdout and human-readable stderr. flowchart TD
A[CLI invocation] --> B[Onboard registration]
B --> C[Shared store factory]
C --> D[Blank selector validation]
D --> E[Expected CLI error]
E --> F[Root failure renderer]
F --> G[JSON stdout and remedy stderr]
Technical reviewBest possible solution: Merge the existing focused classifier change once required CI passes. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the failure path, and contributor plus collaborator CLI captures demonstrate it on the unchanged base implementation; this read-only review executed no target code. Is this the best way to solve the issue? The patch fixes classification at the existing shared validation owner, preserving the message, rejection timing, renderer, and store behavior without adding another error path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 33a1413e7be4. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests 0. Total +1 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:02 AM ET / 09:02 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
CLI proof at f292960 against merge-base 816cb80 (host, source tier via ocx; isolated HOME/config/state; no Gateway). Confirmed the real registration route: resolveRecommendationAgentOption uses readStringValue, which preserves whitespace. The existing blank-selector guard receives " ". The error string is unchanged; only its classification changes. Command: Base stdout and candidate stdout (product JSON): {"ok":false,"error":{"type":"cli_error","message":"--agent must not be blank"}}Base stderr (excluding ocx setup diagnostics): Candidate stderr (excluding ocx setup diagnostics): Both exit 1. Candidate's first invocation also installed dependencies through ocx; installation logs were not counted as CLI output. Controls on both trees:
Host eligibility: only src/commands/onboard-recommendations.ts and its existing test changed; no dependency/workspace/install/script/hook paths. Worktrunk creation used --no-hooks; no git host hook ran. ocx did run the unchanged install lifecycle while preparing dependencies. Production +2/-1; tests +6/-6 (net 0), no allocation file. Contributor commit retained unchanged: PR author shuisadev; distinct commit author SunnyShu [email protected]. No new commit or push needed. |
|
Focused regression receipt (host, vitest-source): copied the candidate test into merge-base 816cb80, then ran |
|
Exact-head gates complete for f292960: CI succeeded, ci-gate green, zero failed or cancelled jobs. Fresh ClawSweeper review is ready, 5/6, exact head (revision 2). after-push.sh completed; no source changes or additional push were needed. |
|
Landed in 918847e. Thanks @shuisadev. |
…son failures (#199523) fix(cli): show the blank --agent error for onboard recommendations --json `openclaw onboard recommendations --agent " " --json` threw its blank-agent check as a plain error, so the JSON failure printed only "The CLI command failed." and the doctor hint instead of the existing "--agent must not be blank". It now throws the same message through the existing expected-CLI-error path, as `models`, `sandbox explain` and `sessions compact` do. Text mode, exit codes and valid-agent output are unchanged. No new text. Evidence: source tier with isolated state and no Gateway; a blank --agent reaches the guard unchanged. With --json, base's stderr had only the generic failure and the doctor hint; this change prints the existing message, with exit code unchanged. Text mode and a valid --agent give the same output on both. Vitest-source: the regression fails on base and 11 tests pass here. Net 0 test lines. Receipts: openclaw/openclaw#199523 (comment). Thanks @shuisadev and @SunnyShu0925. Co-authored-by: SunnyShu <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…son failures (#199523) fix(cli): show the blank --agent error for onboard recommendations --json `openclaw onboard recommendations --agent " " --json` threw its blank-agent check as a plain error, so the JSON failure printed only "The CLI command failed." and the doctor hint instead of the existing "--agent must not be blank". It now throws the same message through the existing expected-CLI-error path, as `models`, `sandbox explain` and `sessions compact` do. Text mode, exit codes and valid-agent output are unchanged. No new text. Evidence: source tier with isolated state and no Gateway; a blank --agent reaches the guard unchanged. With --json, base's stderr had only the generic failure and the doctor hint; this change prints the existing message, with exit code unchanged. Text mode and a valid --agent give the same output on both. Vitest-source: the regression fails on base and 11 tests pass here. Net 0 test lines. Receipts: openclaw/openclaw#199523 (comment). Thanks @shuisadev and @SunnyShu0925. Co-authored-by: SunnyShu <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…son failures (openclaw#199523) fix(cli): show the blank --agent error for onboard recommendations --json `openclaw onboard recommendations --agent " " --json` threw its blank-agent check as a plain error, so the JSON failure printed only "The CLI command failed." and the doctor hint instead of the existing "--agent must not be blank". It now throws the same message through the existing expected-CLI-error path, as `models`, `sandbox explain` and `sessions compact` do. Text mode, exit codes and valid-agent output are unchanged. No new text. Evidence: source tier with isolated state and no Gateway; a blank --agent reaches the guard unchanged. With --json, base's stderr had only the generic failure and the doctor hint; this change prints the existing message, with exit code unchanged. Text mode and a valid --agent give the same output on both. Vitest-source: the regression fails on base and 11 tests pass here. Net 0 test lines. Receipts: openclaw#199523 (comment). Thanks @shuisadev and @SunnyShu0925. Co-authored-by: SunnyShu <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
openclaw onboard recommendations --agent " " --jsonanswers with the generic wrapper pair[openclaw] The CLI command failed./[openclaw] For help, run openclaw doctor.and never shows the actionable--agent must not be blanktext that the same command prints in the human output, so scripts and agents that parse--jsoncannot tell what to fix.--agentguard increateDefaultOnboardingRecommendationsStorethrows a plainError, so the structured-output renderer treats it as an unexpected crash instead of an expected CLI failure. The remedy is only present inside the JSON envelope, while stderr shows the two generic wrapper lines.throwExpectedCliErrorowner so the failure is classified as an expected CLI error; the JSON renderer then prints the same one-line remedy to stderr that the human lane already prints.src/commands/onboard-recommendations.tsadds one import and replacesthrow new Error("--agent must not be blank")withthrowExpectedCliError("--agent must not be blank"). The regression coverage is folded into the existingit.eachcase insrc/commands/onboard-recommendations.test.tsby asserting the error category next to the existing message assertion."type": "cli_error"), the stored recommendation offer, and every other selector guard in this command family (for exampleUnknown agent id "writer!"stays a plainError).Why This Change Was Made
The CLI already has a single owner for "this failure is expected, show the remedy" (
throwExpectedCliErrorinsrc/cli/expected-cli-error.ts), and the sibling guards converted in recently merged PRs use it. Reusing that owner keeps the structured-output contract consistent instead of adding a second classification path.recommendations,acknowledge,refresh) share the same store factory and therefore get the same remedy for free.register.onboard.tsand rethrowing a new error was rejected — it duplicates the message in a second place and would not cover future callers of the shared factory. Editing the JSON renderer to special-case this message was rejected as an over-broad change touching every command.cmpresults below).User Impact
Operators and automation running
openclaw onboard recommendations --agent " " --jsonnow see--agent must not be blankon stderr and can correct the invocation without digging into the JSON envelope. Human-output users, the JSON payload, and the exit status are unchanged.Evidence
origin/main,816cb80)f292960)onboard recommendations --agent " " --jsonstderr[openclaw] The CLI command failed.+[openclaw] For help, run \openclaw doctor`.` (remedy missing)--agent must not be blankonboard recommendations --agent " "(human lane) stderr--agent must not be blank--agent must not be blank(unchanged)onboard recommendations --json(control, no blank selector) stdout[], exit 0[], exit 0 (byte-identical){"ok":false,"error":{"type":"cli_error","message":"--agent must not be blank"}}, exit 1src/commands/onboard-recommendations.test.tsBoth arms are real
cliStartupbuilds of the same tree, run through the shipped launcher;--versionself-reports the two commits:Each cell is a complete user command in a fresh, isolated scratch
HOME/ state / XDG runtime directory, with no credentials and no mocks:The Node security warning and the log-append note come from the scratch environment and are identical on both arms; the only differing line is the remedy.
Unchanged outputs are compared byte for byte across the two builds:
The built bundles show the executed form (base still throws a plain
Error, head uses the shared owner):Regression test, pre-fix source with the new assertion kept (RED), then the fixed source (GREEN):
Open PR collision check: searched open pull requests by changed-file list and by
onboard/recommendations/must not be blankkeywords; no open pull request touchessrc/commands/onboard-recommendations.tsor its test file.What was not tested: nothing beyond the above matrix — the guard is input validation evaluated before any config or store access, so there is no further runtime state to exercise.