Skip to content

fix(cli): explain unknown ids in devices reject and remove - #190299

Merged
obviyus merged 5 commits into
openclaw:mainfrom
jerome-queck:fix/devices-unknown-id-reason
Nov 8, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
jerome-queck:fix/devices-unknown-id-reason

Conversation

@jerome-queck

@jerome-queck jerome-queck commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #190293

What Problem This Solves

openclaw devices reject <id> and openclaw devices remove <id> with an id the Gateway does not know printed only The CLI command failed. (exit 1). The Gateway's INVALID_REQUEST unknown requestId / unknown deviceId reason was lost in text mode, and the JSON envelope carried the bare Gateway string.

User Impact

Text and --json callers now get No pending device request matches <id> / No paired device matches <id> plus a openclaw devices list hint, the same wording devices approve already uses. Exit code stays 1. Other Gateway failures still go to the root failure handler unchanged.

Why

runDevicesDeleteCommand called device.pair.reject|remove without the unknown-id handling devices approve has. The fix catches only the unknown-id refusal for the requested field and routes it through the existing failDevicesCommand. The isUnknownRequestIdError helper moves to src/cli/devices-cli.unknown-id.ts and takes the field, so devices-cli.runtime.ts does not grow past the line-cap ratchet. The moved helper now narrows with in checks instead of a type assertion, so the runtime file's assertion-safety baseline shrinks from 9 to 8.

Evidence

Linux, isolated HOME, a real local Gateway from this tree (gateway run --auth token --bind loopback), the same Gateway for both runs.

Before (main devices-cli.runtime.ts):

$ openclaw devices reject does-not-exist --token <local>
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
$ openclaw devices remove does-not-exist --token <local>
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
$ openclaw devices reject does-not-exist --json --token <local>
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "unknown requestId"

After (head 56ea4f0):

$ openclaw devices reject does-not-exist --token <local>
No pending device request matches does-not-exist. Run openclaw devices list and retry with the current requestId.
# exit=1
$ openclaw devices remove does-not-exist --token <local>
No paired device matches does-not-exist. Run openclaw devices list and retry with the current deviceId.
# exit=1
$ openclaw devices reject does-not-exist --json --token <local>
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "No pending device request matches does-not-exist. Run openclaw devices list and retry with the current requestId."
  }
}
No pending device request matches does-not-exist. Run openclaw devices list and retry with the current requestId.
# exit=1

Scoped tests: vitest run --config test/vitest/vitest.cli.config.ts src/cli/devices-cli.test.ts: 43 passed. The two new unknown-id text cases fail on the main runtime (2 failed | 41 passed). New coverage: text and JSON for both commands, and a non-unknown-id failure that still reaches the root handler.

@clawsweeper

clawsweeper Bot commented Nov 1, 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: S labels Nov 1, 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. labels Nov 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 1, 2026
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Head abf985f fixes the assertion-safety ratchet: the moved isUnknownRequestIdError helper now narrows with in checks instead of a type assertion, and the runtime file's baseline shrinks from 9 to 8. Behaviour is unchanged from the live-Gateway proof in the body. src/cli/devices-cli.test.ts passes (43/43).

@clawsweeper

clawsweeper Bot commented Nov 1, 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Explain unknown IDs in devices reject and remove with a specific error and a devices list recovery hint.

Example: Run openclaw devices remove does-not-exist against an authorized Gateway.

  • Before: The command prints a generic failure and suggests Doctor.
  • After: The command explains that no paired device matches does-not-exist, suggests devices list, and exits with status 1.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, complete diagnostics repair with real-entry-point proof, meaningful regressions, and successful exact-head checks.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied terminal output exercises the real devices CLI against an isolated token-authenticated Linux Gateway, showing both unknown-ID text refusals, JSON rejection output, actionable recovery hints, and exit status 1; subsequent changes preserve that behavior.
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 receive a generic failure instead of learning that their device or request ID is unknown and how to select a current ID.
Reason: The patch extends the existing approval diagnostic pattern to the two affected commands with no new product policy or capability.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI diagnostics bug with a focused change, relevant regression coverage, and sufficient real-Gateway proof; no actionable defects were found.

Priority: P2
Reviewed head: 26da769c2e313f1566d1065ed8c14b10c5d8f353

Before merge

None.

Findings

None.

Agent review details

How this fits together

Registered device CLI commands send pairing RPCs to the Gateway; the command runtime translates matching unknown-ID refusals into human diagnostics or the existing JSON failure envelope.

flowchart LR
  A[Device CLI command] --> B[Device command runtime]
  B --> C[Gateway pairing RPC]
  C --> D[Unknown ID refusal]
  D --> E[Shared ID classifier]
  E --> F[Existing failure output]
Loading

Technical review

Best possible solution:

Retain this focused command-boundary fix using the existing classifier and failure-output owner.

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

Current-main source shows the precise Gateway refusal reaching generic text rendering, and the contributor supplies matching real-Gateway output; no target code was executed during this review.

Is this the best way to solve the issue?

The fix preserves Gateway authorization and successful operations, shares the existing approval classifier, and routes refusals through established output handling without new state or configuration.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Unknown-request classifier keeps the original intent (fc97e92: Surface useful node-approval guidance when a device approval uses an unknown request ID, including the administrative retry path.)
  • Shared reject/remove command runtime keeps the original intent (4bf68b9: Consolidate equivalent command execution and reporting while preserving operation-specific behavior.)
  • Device refusal output keeps the original intent (15305cc: Emit one root-owned JSON failure document for device-command refusals while retaining text diagnostics and nonzero exits.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff adds unknown-ID handling to the existing delete-command owner, moves the approval classifier without retaining a competing implementation, and reduces the assertion baseline. (src/cli/devices-cli.runtime.ts:699, 26da769c2e31)
  • Current-main gap: Current main still directly awaits reject/remove RPCs without handling unknown IDs, leaving their reasons subject to generic root failure rendering. (src/cli/devices-cli.runtime.ts:714, 5e6d9a2781d6)
  • Gateway refusal contract: The Gateway emits INVALID_REQUEST with unknown requestId or unknown deviceId when the respective operation cannot find its target; this PR changes only presentation of those refusals. (src/gateway/server-methods/devices.ts:472, 26da769c2e31)
  • Contributor production proof: The PR body supplies isolated Linux real-Gateway before/after output for both text commands and JSON rejection, including actionable messages and exit status 1; it also reports regressions failing on the main runtime and passing with the fix. (56ea4f08156d)
  • Proof remains applicable: Changes since the demonstrated revision replace a type assertion with equivalent property narrowing and adopt the existing dependency-light ExpectedCliError import; the demonstrated command behavior remains intact. (src/cli/devices-cli.unknown-id.ts:9, 26da769c2e31)
  • Existing output ownership: The merged JSON-refusal repair established failDevicesCommand to reuse root JSON rendering while preserving text errors and nonzero exits; this PR follows that contract. (src/cli/devices-cli.runtime.ts:592, 15305ccd53de)

PR surface

Source +15, Tests +35, Other 0. Total +50 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 32 17 +15
Tests 1 35 0 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 4 68 18 +50

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The bug obscures recovery guidance in a bounded administrative CLI workflow without changing pairing outcomes.
  • 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-01T12:39:31.808Z sha abf985f :: needs maintainer review before merge. :: none

Reviewed November 2, 2026, 11:42 PM ET / November 3, 2026, 04:42 UTC (Revision 2).

…d-reason

# Conflicts:
#	src/cli/devices-cli.runtime.ts
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@obviyus when you have a moment, this is ClawSweeper 5/5/5 and ready for maintainer look; happy to adjust anything.

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Nov 3, 2026
@jerome-queck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 3, 2026
@obviyus
obviyus merged commit 795a03f into openclaw:main Nov 8, 2026
129 checks passed
@obviyus

obviyus commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Merged via squash.

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

* fix(cli): explain unknown ids in devices reject and remove

* test(cli): document the unknown-id gateway error assertion

* fix(cli): narrow the unknown-id gateway error without a type assertion

* chore(cli): shrink devices runtime assertion baseline

---------

Co-authored-by: jerome-queck <[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: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

[Bug]: devices reject / devices remove with an unknown id print only 'The CLI command failed.' and hide the unknown requestId/deviceId reason

2 participants