Skip to content

fix(cli): surface id rebind option remedies instead of a generic failure - #197719

Merged
obviyus merged 2 commits into
openclaw:mainfrom
shuisadev:fix/id-cli-rebind-remedy-393
Nov 12, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
shuisadev:fix/id-cli-rebind-remedy-393

Conversation

@shuisadev

@shuisadev shuisadev commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Running openclaw id rebind --yes (without --kit-stdin) — or an id rebind invocation with a malformed --binding-seq, a missing --code under --kit-stdin, or a recovery kit that cannot sign for this claw — reports only the generic two-line failure:

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

The actual remedy (e.g. --yes needs --kit-stdin: type the recovery kit at the prompt otherwise.) is swallowed, and the user is pointed at an unrelated command. Rebinding keys is an account-recovery path, so the lost guidance is exactly what the user needs.

  • Problem: the id rebind action throws plain Errors for four user-facing refusals; the root failure renderer only prints the cause for ExpectedCliError, so the remedies are hidden.
  • Solution: promote those four throws to throwExpectedCliError(...) so the existing renderer prints the remedy.
  • What changed: src/cli/id-cli.ts (4 throws) and one regression file, src/cli/id-cli.commands.test.ts, covering all four.
  • What did NOT change: control flow, exit codes, and the two Cancelled. user-abort paths.

Why This Change Was Made

The canonical owner for surfacing user-facing CLI errors is throwExpectedCliError (src/cli/expected-cli-error.ts); adjacent command families (agent exec, backup, nodes, gateway, connect, capability) already route through runtime wrappers that map to it. Only the id registration chain was bare. This change aligns id rebind with that convention without altering behavior beyond the rendered message.

  • Best fix: using throwExpectedCliError keeps the message identical to the existing human text and requires no new rendering code.
  • Alternative: wrapping the .action in a try/catch that rethrows as ExpectedCliError — rejected because it would also catch unrelated errors, and the four throws already carry the correct text.
  • Risk: none beyond the visible message change; exit code stays 1.

User Impact

When id rebind is invoked with a wrong or missing option, the user now sees the specific remedy (e.g. --yes needs --kit-stdin: ...) instead of a generic failure and an unrelated openclaw doctor hint.

Evidence

Real CLI, throwaway state dir (OPENCLAW_STATE_DIR=/tmp/oc-id-proof-*, empty {} config, no Gateway), same commands on both arms. src/cli/id-cli.ts is the only production file this PR changes, and it is identical to the reviewed head.

before: base collapses all three refusals into the generic pair; after: this PR prints the remedy

Before/after, same commands on both arms:

openclaw id rebind … Before — base (origin/main) After — this PR exit
--yes [openclaw] The CLI command failed. + doctor hint --yes needs --kit-stdin: type the recovery kit at the prompt otherwise. 1
--kit-stdin same generic pair --kit-stdin needs --code <link-code> from your OpenClaw ID account. 1
--kit-stdin --yes --code test-link-code --binding-seq 0 same generic pair --binding-seq must be a positive whole number. 1

The fourth refusal (describeSignRefusal) is only reachable after a live openclawId.authority rebind_prepare answer, so it has no Gateway-free CLI run; the regression below drives it with that RPC mocked and a kit from another claw.

Committed regression, before/after the fix:

# before: base source with the new regression in place
$ git show origin/main:src/cli/id-cli.ts > src/cli/id-cli.ts
$ npx vitest run --config test/vitest/vitest.cli.config.ts src/cli/id-cli.commands.test.ts
 × |cli| src/cli/id-cli.commands.test.ts > shows the remedy for --yes without --kit-stdin as an ExpectedCliError, not a generic failure 15ms
   → expected Error: --yes needs --kit-stdin: type the … to be an instance of ExpectedCliError
 × |cli| src/cli/id-cli.commands.test.ts > shows the remedy for --kit-stdin without --code as an ExpectedCliError, not a generic failure 7ms
   → expected Error: --kit-stdin needs --code <link-cod… to be an instance of ExpectedCliError
 × |cli| src/cli/id-cli.commands.test.ts > shows the remedy for a non-positive --binding-seq as an ExpectedCliError, not a generic failure 7ms
   → expected Error: --binding-seq must be a positive w… to be an instance of ExpectedCliError
 × |cli| src/cli/id-cli.commands.test.ts > shows a kit from another claw as an ExpectedCliError 9ms
   → expected Error: This recovery kit is for another c… to be an instance of ExpectedCliError
 Test Files  1 failed (1)
      Tests  4 failed | 8 passed (12)

# after: this PR
$ git checkout HEAD -- src/cli/id-cli.ts
$ npx vitest run --config test/vitest/vitest.cli.config.ts src/cli/id-cli.commands.test.ts
 Test Files  1 passed (1)
      Tests  12 passed (12)

Both shapes go through the shipped registerIdCli registration and parseAsync, so option parsing and the throwing code path are the real ones.

Open PR collision check: searched the latest open PRs' changed-files for src/cli/id-cli.ts; none touched it. Sibling known entries about gateway lifecycle refusal, attach, models auth login, and plugins pack are different files/functions, so there is no overlap.

@clawsweeper

clawsweeper Bot commented Nov 12, 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 cli CLI command changes size: XS labels Nov 12, 2026
@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. P2 Normal backlog priority with limited blast radius. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes four OpenClaw ID rebind refusals display their existing remedies through the standard CLI error renderer.

Example: Run openclaw id rebind --yes without --kit-stdin.

  • Before: The CLI prints a generic failure and suggests openclaw doctor.
  • After: The CLI prints “--yes needs --kit-stdin: type the recovery kit at the prompt otherwise.” and still exits with code 1.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A small, correct diagnostic repair with shipped-entry-point proof, one focused regression, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The inspected image and exact-head maintainer report exercise three refusals through the real CLI in isolated empty state, showing actionable messages and unchanged exit codes; the signing-refusal branch was inspected structurally and is not claimed as live-tested.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Invalid rebind options and signing refusals hide their existing recovery guidance behind a generic failure.
Reason: The change restores documented, actionable diagnostics without adding options, changing defaults, or altering the recovery ceremony.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI diagnostic bug with a focused change and convincing before/after proof; no actionable defects were found.

Priority: P2
Reviewed head: 3e7f6b409bfba2df55d0c4da182a9d326f85df06

Before merge

None.

Findings

None.

Agent review details

How this fits together

The registered ID command validates recovery options and signs prepared bindings; expected refusals pass to the root CLI renderer for human or JSON output.

flowchart TD
  A[CLI arguments] --> B[Registered ID command]
  B --> C[Option validation]
  C --> D[Gateway preparation and kit signing]
  C --> E[Expected CLI error]
  D --> E
  E --> F[Root failure renderer]
  F --> G[Actionable output]
Loading

Technical review

Best possible solution:

Merge the focused error-classification fix once the existing exact-head CI gate passes.

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

Current-main source establishes the plain-error-to-generic-output path, corroborated by supplied before/after CLI evidence; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Using the existing expected-error owner at the four refusal producers is the smallest complete fix and preserves unexpected-error handling.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Four rebind refusal producers keeps the original intent (5f2f21a: The original recovery ceremony supplied precise option and signing refusals while keeping recovery local and preserving committed outcomes; no intentional requirement to hide those remedies was found.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 5f2f21a adds src/cli/id-cli.ts:100 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5f2f21a7ee19; files: src/cli/id-cli.ts)
  • Jerome: Raw commit bc097bf adds src/cli/expected-cli-error.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; 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 7 4 +3
Tests 1 9 10 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 16 14 +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:

No label changes.

Label justifications:

  • P2: Specific recovery-command mistakes hide actionable guidance, with impact limited to this advanced CLI workflow.
  • 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.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 (2 earlier review cycles)
  • reviewed 2026-11-12T12:29:54.821Z sha e303f6cfa07b0cc969e9085c5fcefde4d386fd95 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-12T12:49:40.486Z sha 012adab :: needs maintainer review before merge. :: none

Reviewed November 12, 2026, 8:47 AM ET / 13:47 UTC (Revision 3).

registerIdCli's status/rebind/publish .action handlers call runStatus/runRebind,
which throw plain Errors for four user-facing option mistakes: --yes needs
--kit-stdin, --binding-seq must be a positive whole number, --kit-stdin needs
--code, and signature refusal. The root failure renderer only prints the cause
for ExpectedCliError, so these remedies were swallowed behind a generic
"The CLI command failed" / "For help, run openclaw doctor" message, pointing
users at an unrelated command.

Promote the four throws to throwExpectedCliError so the existing renderer prints
the remedy. No control-flow or exit-code change.
@shuisadev
shuisadev force-pushed the fix/id-cli-rebind-remedy-393 branch from e303f6c to 012adab Compare November 12, 2026 12:44
@shuisadev

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: applying reviewed decision.

I am applying the reviewed decision for this pull request: fix(cli): surface id rebind option remedies instead of a generic failure This is item 1/1 in the current shard. Shard 1/1.

This transient lease prevents a newer review from overlapping label, comment, or close mutations.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Maintainer proof for head 3e7f6b4 (built CLI, node openclaw.mjs, secretless node:24.22.1 container, empty {} config, no Gateway).

Main 4e77ab022143 vs this PR, same commands:

openclaw id rebind … main this PR exit
--yes The CLI command failed. + doctor hint --yes needs --kit-stdin: type the recovery kit at the prompt otherwise. 1 → 1
--kit-stdin same generic pair --kit-stdin needs --code <link-code> from your OpenClaw ID account. 1 → 1
--kit-stdin --yes --code test-link-code --binding-seq 0 same generic pair --binding-seq must be a positive whole number. 1 → 1

Controls, identical on both arms:

  • id rebind --help: same text, exit 0.
  • Valid rebind without Gateway credentials: same "requires credentials" message, exit 1.
  • Unexpected internal error (--url not-a-url): still the generic The CLI command failed. pair, exit 1.

The fourth throw (kit for another claw) needs a live rebind_prepare answer, so it is covered by the unit test only.

Maintainer edit: the regression is now one compact case (--yes refusal is an ExpectedCliError) and the shared run helper is shorter, so the test file is net -1 line. id-cli.commands.test.ts passes (9 tests); oxfmt clean. Production diff is still only the four throw types.

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

1 similar comment
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Nov 12, 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus
obviyus merged commit c0f0a42 into openclaw:main Nov 12, 2026
115 of 116 checks passed
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in c0f0a42. Thanks @shuisadev and @SunnyShu0925.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…ure (openclaw#197719)

fix(cli): show existing id rebind errors instead of the generic failure

openclaw id rebind threw plain errors for its own usage and input checks, so the CLI replaced them with the generic "The CLI command failed." and the user never saw the reason, such as "--yes needs --kit-stdin". Those four throws now use throwExpectedCliError with the same existing text. What rebind accepts, refuses or does is unchanged, and unexpected internal errors still show the generic message. No new text.

Evidence: the built CLI in a secretless node:24.22.1 container with an empty config, main once and candidate once. id rebind --yes, --kit-stdin without --code, and a non-positive --binding-seq printed the generic failure on main and print their existing messages with this change, all with exit 1. id rebind --help, a valid rebind without Gateway credentials, and an invalid --url behave the same on both. One compact test case, at -1 net test lines. Details: openclaw#197719 (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

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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