Skip to content

fix(cli): surface onboard recommendations blank --agent remedy in --json failures - #199523

Merged
obviyus merged 1 commit into
openclaw:mainfrom
shuisadev:fix/bug-434-onboard-blank-agent-remedy
Nov 15, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
shuisadev:fix/bug-434-onboard-blank-agent-remedy

Conversation

@shuisadev

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw onboard recommendations --agent " " --json answers 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 blank text that the same command prints in the human output, so scripts and agents that parse --json cannot tell what to fix.

  • Problem: the blank --agent guard in createDefaultOnboardingRecommendationsStore throws a plain Error, 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.
  • Solution: route that guard through the existing throwExpectedCliError owner 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.
  • What changed: src/commands/onboard-recommendations.ts adds one import and replaces throw new Error("--agent must not be blank") with throwExpectedCliError("--agent must not be blank"). The regression coverage is folded into the existing it.each case in src/commands/onboard-recommendations.test.ts by asserting the error category next to the existing message assertion.
  • What did NOT change: message text, exit code 1, the human-readable stderr line, the JSON envelope shape ("type": "cli_error"), the stored recommendation offer, and every other selector guard in this command family (for example Unknown agent id "writer!" stays a plain Error).

Why This Change Was Made

The CLI already has a single owner for "this failure is expected, show the remedy" (throwExpectedCliError in src/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.

  • Best fix: convert the guard at its definition rather than post-processing the error in the command wrapper, because all three subcommands (recommendations, acknowledge, refresh) share the same store factory and therefore get the same remedy for free.
  • Alternative(s): catching the error in register.onboard.ts and 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.
  • Risk: the only observable change is that stderr now shows the remedy instead of the generic wrapper pair for an expected, user-input failure; the JSON envelope, exit code, and human lane are byte-identical (see the cmp results below).

User Impact

Operators and automation running openclaw onboard recommendations --agent " " --json now see --agent must not be blank on 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

Case Before (base origin/main, 816cb80) After (this head, f292960)
onboard recommendations --agent " " --json stderr [openclaw] The CLI command failed. + [openclaw] For help, run \openclaw doctor`.` (remedy missing) --agent must not be blank
onboard 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)
JSON envelope for the blank selector {"ok":false,"error":{"type":"cli_error","message":"--agent must not be blank"}}, exit 1 byte-identical, exit 1
src/commands/onboard-recommendations.test.ts `1 failed 10 passed (11)`

Both arms are real cliStartup builds of the same tree, run through the shipped launcher; --version self-reports the two commits:

$ node openclaw.mjs --version   # frozen origin/main build
OpenClaw 2026.11.3 (816cb80)

$ node openclaw.mjs --version   # this head build
OpenClaw 2026.11.3 (f292960)

Each cell is a complete user command in a fresh, isolated scratch HOME / state / XDG runtime directory, with no credentials and no mocks:

$ node openclaw.mjs onboard recommendations --agent " " --json   # base
openclaw: SECURITY WARNING: Node.js 24.19.0 is below the recommended security patch level. ...
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
[openclaw] log file append failed; records dropped; check that the path is a writable regular file; file=openclaw-2026-11-15.log
exit 1

$ node openclaw.mjs onboard recommendations --agent " " --json   # this head
openclaw: SECURITY WARNING: Node.js 24.19.0 is below the recommended security patch level. ...
--agent must not be blank
[openclaw] log file append failed; records dropped; check that the path is a writable regular file; file=openclaw-2026-11-15.log
exit 1

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:

$ cmp base/json.out head/json.out && echo "json envelope identical"
json envelope identical
$ cmp base/ctl_json.out head/ctl_json.out && echo "control json identical"
control json identical
$ cmp base/text.err head/text.err && echo "text lane identical"
text lane identical

The built bundles show the executed form (base still throws a plain Error, head uses the shared owner):

# base: dist/onboard-recommendations-*.mjs
...if(e!==void 0&&!t)throw new Error(`--agent must not be blank`);...

# head: dist/onboard-recommendations-*.mjs
...if(e!==void 0&&!t)throwExpectedCliError(`--agent must not be blank`);...

Regression test, pre-fix source with the new assertion kept (RED), then the fixed source (GREEN):

$ npx vitest run src/commands/onboard-recommendations.test.ts   # base production code, new assertion
 × onboard recommendations read selection > rejects invalid selector '   ' without changing the default offer
   → expected Error: --agent must not be blank to have property "name" with value 'ExpectedCliError'
      Tests  1 failed | 10 passed (11)

$ npx vitest run src/commands/onboard-recommendations.test.ts   # this head
      Tests  11 passed (11)

Open PR collision check: searched open pull requests by changed-file list and by onboard / recommendations / must not be blank keywords; no open pull request touches src/commands/onboard-recommendations.ts or 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.

@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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. 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

Classify 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.

  • Before: Stderr reports a generic command failure and recommends Doctor.
  • After: Stderr reports --agent must not be blank; JSON output and exit code 1 remain unchanged.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal complete fix with real CLI proof, a demonstrated red/green regression, and no actionable findings; broad CI is still running.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The body supplies shipped-launcher base/head captures, and obviyus independently records the real CLI registration route at the reviewed head with isolated state: blank-selector stderr becomes actionable while JSON, exit status, human output, and valid-selector controls remain equal.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: JSON-mode users see a generic failure on stderr instead of the existing explanation that their agent selector is blank.
Reason: The change restores the established expected-error presentation using its existing owner and leaves successful invocations and structured output intact.

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
Reviewed head: f2929606979d89a48b7ea0dc6bedd70fb0d8265d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Blank-selector validation keeps the original intent (52e6b0b: Reject explicit blank selection before accessing the default workspace or changing recommendation records.)
  • Existing invalid-selector regression keeps the original intent (test(commands,gateway,plugins,ui): remove low-value tests (batch d039) #168028: Consolidate low-value test variants while retaining independent rejection and state-preservation coverage; the patch extends the retained table rather than adding scaffolding.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • TheHandAIMan: Raw commit 52e6b0b adds src/commands/onboard-recommendations.ts:48 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 52e6b0bb7f3a; files: src/commands/onboard-recommendations.ts)

PR surface

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

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

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 status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on maintainer: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This improves diagnostics for an invalid advanced CLI invocation; the JSON envelope already contains the error and valid commands continue working.
  • 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-15T08:36:54.947Z sha f292960 :: blocked before merge. :: none

Reviewed November 15, 2026, 4:02 AM ET / 09:02 UTC (Revision 2).

@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:

@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

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: ocx src -- onboard recommendations --agent " " --json

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):

[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.

Candidate stderr (excluding ocx setup diagnostics):

--agent must not be blank

Both exit 1. Candidate's first invocation also installed dependencies through ocx; installation logs were not counted as CLI output.

Controls on both trees:

  • Same command without --json: stderr --agent must not be blank, exit 1; compared equal.
  • --agent main --json: stdout [], exit 0; compared equal.
  • --agent main text mode: stdout No stored onboarding recommendations., exit 0; compared equal.
  • All four corresponding exit-code captures compared equal.

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.

@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Focused regression receipt (host, vitest-source): copied the candidate test into merge-base 816cb80, then ran ocx test src/commands/onboard-recommendations.test.ts on both trees. Base failed only the whitespace-selector case: expected error name ExpectedCliError, received Error. Candidate passed all 11 tests. The existing unknown-agent and state-preservation coverage remains intact. CLI and control receipts: #199523 (comment)

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 15, 2026
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

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.

@obviyus
obviyus merged commit 918847e into openclaw:main Nov 15, 2026
128 of 129 checks passed
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Landed in 918847e. Thanks @shuisadev.

github-actions Bot pushed a commit to zobdansleculzobdanslecul5562/openclaw that referenced this pull request Nov 15, 2026
…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]>
github-actions Bot pushed a commit to Shiran20016061/openclaw that referenced this pull request Nov 15, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…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]>
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.

3 participants