Skip to content

fix(cli): keep nodes list consistent with live paired nodes - #50970

Closed
ChroniCat wants to merge 3 commits into
openclaw:mainfrom
ChroniCat:fix/nodes-list-paired-consistency
Closed

ChroniCat wants to merge 3 commits into
openclaw:mainfrom
ChroniCat:fix/nodes-list-paired-consistency

Conversation

@ChroniCat

Copy link
Copy Markdown
Contributor

Fixes #50847.

Keeps openclaw nodes list consistent with openclaw nodes status by merging live paired nodes from node.list when node.pair.list is stale or temporarily missing a paired entry.

Includes an e2e regression test covering the case where nodes status sees a paired live node but nodes list would otherwise report Paired: 0.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Mar 20, 2026
@greptile-apps

greptile-apps Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes an inconsistency between openclaw nodes list and openclaw nodes status by introducing a mergePairedNodes helper that merges live paired nodes from node.list into the results when node.pair.list is stale or temporarily incomplete. A regression e2e test covering the stale-pairing-list scenario is also added.

Key changes:

  • New mergePairedNodes function in register.status.ts that supplements node.pair.list data with live paired nodes from node.list (only adding entries absent from the pairing list).
  • The nodes list command now always calls node.list (previously it was only called when --connected or --last-connected filters were active). This is intentional to enable the merge, but it does add an extra RPC call to every unfiltered nodes list invocation.
  • filteredLabel now correctly references pairedNodes.length (merged total) instead of the raw paired.length from node.pair.list.
  • The new e2e test validates the core fix: when node.pair.list returns 0 paired nodes but node.list has a live paired node, nodes list still reports Paired: 1 and shows the node's display name.

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk — the fix is scoped, well-tested, and the logic is straightforward.
  • The change is small, targeted, and backed by a direct regression test. The merge logic correctly skips non-paired and already-known nodes, and the filteredLabel denominator is updated consistently. The only issues found are a leftover optional chain (?.) on a Map that can no longer be null, which is a style concern and not a correctness problem. The added unconditional node.list call is intentional and noted.
  • No files require special attention, though reviewers may want to verify the performance impact of always calling node.list in unfiltered nodes list invocations.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/cli/nodes-cli/register.status.ts
Line: 344-345

Comment:
**Unnecessary optional chaining on non-nullable map**

After the refactor, `connectedById` is now always a `Map` (created unconditionally on line 340) and can never be `null` or `undefined`. The `?.` optional chaining at lines 344 and 395 is therefore unnecessary and could be misleading to future readers who might wonder under what circumstances `connectedById` could be absent.

```suggestion
              const live = connectedById.get(node.nodeId);
```

The same applies at line 395:
```suggestion
              const live = connectedById.get(n.nodeId);
```

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

Last reviewed commit: "fix(cli): keep nodes..."

Comment thread src/cli/nodes-cli/register.status.ts Outdated
Comment on lines 344 to 345
const live = connectedById?.get(node.nodeId);
if (!live?.connected) {

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.

P2 Unnecessary optional chaining on non-nullable map

After the refactor, connectedById is now always a Map (created unconditionally on line 340) and can never be null or undefined. The ?. optional chaining at lines 344 and 395 is therefore unnecessary and could be misleading to future readers who might wonder under what circumstances connectedById could be absent.

Suggested change
const live = connectedById?.get(node.nodeId);
if (!live?.connected) {
const live = connectedById.get(node.nodeId);

The same applies at line 395:

Suggested change
const live = connectedById?.get(node.nodeId);
if (!live?.connected) {
const live = connectedById.get(n.nodeId);
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/nodes-cli/register.status.ts
Line: 344-345

Comment:
**Unnecessary optional chaining on non-nullable map**

After the refactor, `connectedById` is now always a `Map` (created unconditionally on line 340) and can never be `null` or `undefined`. The `?.` optional chaining at lines 344 and 395 is therefore unnecessary and could be misleading to future readers who might wonder under what circumstances `connectedById` could be absent.

```suggestion
              const live = connectedById.get(node.nodeId);
```

The same applies at line 395:
```suggestion
              const live = connectedById.get(n.nodeId);
```

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

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

ℹ️ 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".

)
: null;
const filteredPaired = paired.filter((node) => {
const liveNodes = parseNodeList(await callGatewayCli("node.list", opts, {}));

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.

P1 Badge Avoid requiring read scope for plain nodes list

This unconditional node.list fetch makes openclaw nodes list fail for operators that only have pairing permissions. In src/gateway/method-scopes.ts, node.pair.list is allowed under operator.pairing, but node.list is gated by operator.read, so an unfiltered list request that used to succeed can now abort with an authorization error even though it only needs pairing data.

Useful? React with 👍 / 👎.

)
: null;
const filteredPaired = paired.filter((node) => {
const liveNodes = parseNodeList(await callGatewayCli("node.list", opts, {}));

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.

P2 Badge Preserve fallback when the gateway lacks node.list

This new hard dependency on node.list also regresses mixed-version setups where the CLI is newer than the gateway. Other code paths still treat unknown method: node.list as a compatibility case and fall back to node.pair.list (src/cli/nodes-cli/rpc.ts:79-95, src/agents/tools/nodes-utils.ts:41-64), but nodes list now throws before it can show the pairing data, so the command stops working outright against older gateways.

Useful? React with 👍 / 👎.

@ChroniCat

Copy link
Copy Markdown
Contributor Author

The only remaining failing check appears to be unrelated to this PR. It is failing in src/plugins/loader.git-path-regression.test.ts under the general pnpm test shard, while this PR only changes the CLI nodes list/status path. I also ran that regression locally with pnpm exec vitest run src/plugins/loader.git-path-regression.test.ts, and it passed on my side.

@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

Close as superseded by #65772. #50970 targets a real nodes list / nodes status bug, but its implementation makes plain nodes list hard-depend on node.list, matching the existing review concerns about pairing-scope callers and older gateways. The newer open PR #65772 tracks the same remaining work and explicitly adds the fallback and JSON compatibility coverage this PR is missing.

Best possible solution:

Close #50970 as superseded and continue the maintainer review on #65772. The best fix is to make nodes list prefer the effective node.list paired-node view, keep pending data from node.pair.list, preserve the existing JSON pairing metadata contract, and retain a narrow fallback for pairing-only callers and older gateways.

What I checked:

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

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