Skip to content

fix(cli): align nodes list with node status - #51053

Closed
wangji0923 wants to merge 1 commit into
openclaw:mainfrom
wangji0923:fix/nodes-list-status-consistency
Closed

wangji0923 wants to merge 1 commit into
openclaw:mainfrom
wangji0923:fix/nodes-list-status-consistency

Conversation

@wangji0923

Copy link
Copy Markdown

Summary

  • Problem: openclaw nodes status reads the live node.list view, but openclaw nodes list still renders paired nodes from node.pair.list, so gateways using the newer device-pairing path can show a connected node in status while list reports Paired: 0.
  • Why it matters: the CLI and downstream tooling treat nodes list as the paired-node inventory, so the mismatch hides healthy paired nodes.
  • What changed: nodes list now keeps node.pair.list for pending requests, but it builds the paired-node table from node.list first and only falls back to legacy node.pair.list data when node.list is unavailable.
  • What did NOT change (scope boundary): this does not change gateway pairing storage, RPC contracts, or node registration behavior.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • openclaw nodes list now shows the same paired/connected node inventory as openclaw nodes status on gateways that already expose nodes through node.list.
  • Pending pairing requests still appear in openclaw nodes list when no filters are applied.
  • Older gateways that do not implement node.list still fall back to the legacy node.pair.list view.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: Windows 11
  • Runtime/container: Node 22.20.0
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): N/A

Steps

  1. Pair or connect a node through the newer device-pairing path so node.list reports it as paired/connected.
  2. Run openclaw nodes status and confirm the node appears.
  3. Run openclaw nodes list.

Expected

  • Both commands report the same paired node inventory.

Actual

  • nodes status shows the node, while nodes list can report Pending: 0 · Paired: 0 because it only reads the legacy node.pair.list source.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: reproduced the mismatch in the CLI harness by returning a paired node from node.list and an empty node.pair.list, then confirmed nodes list now reports the paired node; also verified the legacy fallback path when node.list is unavailable.
  • Edge cases checked: --connected filtering still works against live node connectivity; pending pairing rows remain visible when no filters are applied.
  • What you did not verify: I did not run this against a live gateway/node pair outside the targeted CLI test harness.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert this PR to restore the previous node.pair.list-only behavior in nodes list.
  • Files/config to restore: src/cli/nodes-cli/register.status.ts
  • Known bad symptoms reviewers should watch for: nodes list omits paired nodes on older gateways that should still fall back to node.pair.list.

Risks and Mitigations

  • Risk: a gateway returns partial node.list rows without paired: true, which could still hide a legacy paired entry.
  • Mitigation: the merge logic keeps legacy node.pair.list metadata and treats matching live rows as paired when a legacy paired entry already exists.

@greptile-apps

greptile-apps Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a real UX inconsistency where openclaw nodes list reported zero paired nodes while openclaw nodes status showed the same nodes as connected, because the two commands read from different RPC sources (node.pair.list vs node.list). The fix is well-scoped: it adds a thin merge layer that reads node.list first and gracefully degrades to node.pair.list for older gateways.

Key findings:

  • Fragile fallback detection (register.status.ts lines 127–136): shouldFallbackToPairList requires the string "node.list" to appear inside the error message before it considers any keyword ("unknown method", "not implemented", etc.). Older gateways that respond with generic errors that omit the method name (e.g. just "unknown method") will not trigger the fallback, causing nodes list to throw — a regression from the pre-PR behaviour where node.list was never called by this command at all.

  • --connected silently returns empty results on fallback gateways (register.status.ts line 427): Before this change, the live-connectivity fetch only happened when hasFilters was true. Now the fetch happens unconditionally, and when it fails the fallback seeds all entries with connected: false. A user running nodes list --connected on an older gateway will now see Paired: 0 with no warning, where they previously received a clear error.

  • Test gap: Both new e2e tests use "unknown method: node.list" as the thrown error string, which satisfies the message.includes("node.list") guard and masks the fragility above. A test that throws just "unknown method" would expose the regression.

Confidence Score: 3/5

  • Safe to merge on gateways that already expose node.list, but risks silent regressions on older gateways depending on their exact error message format.
  • The core logic (merge + fallback) is sound, and the happy-path tests pass. However, the fallback detection heuristic is brittle — a real older gateway could trigger a full error instead of gracefully falling back, and --connected silently returns no results instead of erroring in the fallback path. Both issues affect legacy gateway compatibility, which is the declared compatibility goal of this PR.
  • src/cli/nodes-cli/register.status.ts — specifically shouldFallbackToPairList and the --connected filter path when fallback fires.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/cli/nodes-cli/register.status.ts
Line: 127-136

Comment:
**Fallback may not trigger on gateways with generic error messages**

`shouldFallbackToPairList` requires the string `"node.list"` to appear in the error message before checking for "unknown method", "not implemented", etc. Some older gateways return generic errors without including the method name (e.g. just `"unknown method"` or `"not supported"`). In those cases `message.includes("node.list")` is `false`, the function returns `false`, and `loadPairedNodesForList` re-throws — causing `nodes list` to fail entirely where it never did before (the old implementation never called `node.list` in the `list` command).

Since _we_ are the caller of `node.list`, we already know which method produced the error; the method-name guard in the message is unnecessary and makes the fallback brittle. Consider removing the `node.list` string requirement and trusting the keyword check alone:

```suggestion
function shouldFallbackToPairList(error: unknown): boolean {
  const message = messageFromError(error).toLowerCase();
  return (
    message.includes("unknown method") ||
    message.includes("method not found") ||
    message.includes("not implemented") ||
    message.includes("unsupported")
  );
}
```

The existing test only covers the case where the error explicitly says `"unknown method: node.list"`, which masks this gap.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/cli/nodes-cli/register.status.ts
Line: 425-430

Comment:
**`--connected` silently returns zero results when `node.list` falls back**

Before this PR, the `list` command only called `node.list` when `hasFilters` was true (i.e. `--connected` or `--last-connected` was passed). If `node.list` was unavailable, that code path would throw a clear error.

Now `node.list` is always fetched inside `loadPairedNodesForList` and if it is unavailable, the fallback seeds every entry with `connected: false`. When the user then runs:

```
openclaw nodes list --connected
```

on a gateway that falls back to `node.pair.list`, the filter `!node.connected` drops every entry and the output quietly shows `Pending: 0 · Paired: 0` — even though paired nodes exist. The user gets no indication that connectivity data was unavailable.

Consider emitting a warning when `node.list` was unavailable but filters that require live connectivity data are in use, or document this behaviour in the `--connected` help text.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "CLI: align nodes lis..."

Comment thread src/cli/nodes-cli/register.status.ts Resolved
Comment thread src/cli/nodes-cli/register.status.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70e491d062

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/cli/nodes-cli/register.status.ts Resolved
Comment thread src/cli/nodes-cli/register.status.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3aa6d28c40

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/cli/nodes-cli/register.status.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2602f6807

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/cli/nodes-cli/register.status.ts Resolved
@wangji0923
wangji0923 force-pushed the fix/nodes-list-status-consistency branch from 7fc87c5 to 1f23308 Compare March 26, 2026 03:19
@wangji0923

Copy link
Copy Markdown
Author

Refreshed this PR onto the current upstream/main and kept the scope focused on the original nodes list consistency bug.

This update specifically addresses the legacy-compatibility regressions called out in review:

  • fallback now accepts generic older-gateway errors like unknown method / invalid request / missing read scope without requiring the error text to mention node.list
  • nodes list --connected and --last-connected now fail clearly when live node.list data is unavailable instead of silently showing Paired: 0
  • JSON fallback coverage now preserves the legacy paired metadata through the node.pair.list fallback path

Re-verified with focused checks:

  • pnpm exec oxfmt --check src/cli/nodes-cli/register.status.ts src/cli/program.nodes-basic.e2e.test.ts src/cli/program.test-mocks.ts
  • pnpm exec oxlint src/cli/nodes-cli/register.status.ts src/cli/program.nodes-basic.e2e.test.ts src/cli/program.test-mocks.ts
  • pnpm test -- src/cli/program.nodes-basic.e2e.test.ts -t "falls back to node.pair.list"
  • pnpm test -- src/cli/program.nodes-basic.e2e.test.ts -t "fails clearly for nodes list"
  • pnpm test -- src/cli/program.nodes-basic.e2e.test.ts -t "preserves legacy paired metadata"

@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

PR #51053 should close as superseded by open PR #65772. Current main still has the nodes list/status source-of-truth split, but #65772 is now the active canonical PR for the same CLI fix and includes the same compatibility concerns this PR addressed.

Best possible solution:

Close #51053 as superseded and keep #65772 as the canonical review/landing path for this CLI behavior fix, carrying forward #51053's useful fallback and JSON compatibility considerations.

What I checked:

  • Current main still has the CLI source split: nodes status reads node.list, while unfiltered nodes list reads node.pair.list and only consults node.list for filtered modes. That matches the bug this PR tries to fix, so this is not implemented on main. (src/cli/nodes-cli/register.status.ts:125, 76cf013df507)
  • Gateway contract supports the reported mismatch: node.pair.list returns the node-pairing store, while node.list builds the effective known-node catalog from device pairing, node pairing, and connected node registry state. (src/gateway/server-methods/nodes.ts:565, 76cf013df507)
  • Known-node catalog includes device-paired nodes outside node.pair.list: The catalog test constructs a node-role paired device with pairedNodes: [] and expects listKnownNodes to include that node, which is the exact class of node nodes list can miss when it uses only node.pair.list. (src/gateway/node-catalog.test.ts:10, 76cf013df507)
  • PR fix(cli): align nodes list with node status #51053 latest patch addressed review concerns: The latest head commit 1f23308cd543985380fee3839c13802d1567ea06 adds node.list/node.pair.list merge logic, fallback handling, clear filtered-mode failure, and JSON fallback metadata tests; the author also documented those follow-ups in the PR discussion. (1f23308cd543)
  • Open PR fix(cli): keep nodes list aligned with nodes status #65772 supersedes the same remaining work: PR fix(cli): keep nodes list aligned with nodes status #65772 is open, changes the same CLI files, targets the same nodes list / nodes status mismatch, preserves JSON metadata, and carries newer review history. Its patch stack includes b87df8fd1e460f89320b146c3227c79da6eb6eb2, 5ba24c2b9f714bdc47bc596882ad82aef57673e5, and e78e4d4f3abb5f4a0740fc5b9f1c7927e0683b4b.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 76cf013df507.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Incorrect behavious of commands openclaw nodes list and openclaw nodes status

1 participant