Skip to content

fix(cli): keep nodes list aligned with nodes status - #65772

Closed
skainguyen1412 wants to merge 5 commits into
openclaw:mainfrom
skainguyen1412:fix/nodes-list-sync-65706
Closed

skainguyen1412 wants to merge 5 commits into
openclaw:mainfrom
skainguyen1412:fix/nodes-list-sync-65706

Conversation

@skainguyen1412

Copy link
Copy Markdown
Contributor

Summary

  • Problem: openclaw nodes status used the effective node.list view, while openclaw nodes list still used raw node.pair.list, so the two commands could disagree about which nodes were paired.
  • Why it matters: operators could see Paired: 0 in nodes list even when nodes status showed paired nodes, and scripts consuming nodes list --json needed the existing pairing metadata to remain stable.
  • What changed: nodes list now uses node.list as the effective paired-node source when available, keeps pending from node.pair.list, falls back to pairing-only data for compatibility when unfiltered node.list is unavailable, and preserves raw pairing metadata in --json.
  • What did NOT change (scope boundary): this PR does not change gateway methods, method scopes, pairing storage, or the meaning of pending approval data; filtered modes still depend on node.list because they need live node state.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • 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

Root Cause (if applicable)

  • Root cause: the CLI had two different sources of truth for “paired nodes.” nodes status used the newer effective node catalog from node.list, while nodes list still used the raw node-pairing store from node.pair.list.
  • Missing detection / guardrail: there was no test locking in that nodes list and nodes status should stay aligned, and no test protecting the nodes list --json output contract.
  • Contributing context (if known): earlier changes intentionally made node.list a more accurate effective view of available nodes, but nodes list was not updated in sync with that behavior.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/cli/program.nodes-basic.e2e.test.ts
  • Scenario the test should lock in: nodes list should show effective paired nodes from node.list, preserve pairing-only fallback when unfiltered node.list is unavailable, and keep raw pairing metadata in --json.
  • Why this is the smallest reliable guardrail: the bug lives in CLI command wiring and output shaping across two gateway methods, so a command-level test is more reliable than a narrow helper unit test.
  • Existing test that already covers this (if any): existing nodes list --connected / nodes status --last-connected tests covered parts of the command flow, but not the source-of-truth mismatch or JSON compatibility.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • openclaw nodes list now stays aligned with openclaw nodes status for effective paired nodes.
  • openclaw nodes list without filters keeps working for pairing-scope callers and older gateways by falling back when node.list is unavailable.
  • openclaw nodes list --json preserves existing pairing metadata instead of returning a reduced display-only shape.

Diagram (if applicable)

Before:
[nodes status] -> [node.list effective view] -> [paired nodes shown]
[nodes list]   -> [node.pair.list raw store] -> [could show 0 paired]

After:
[nodes status] -> [node.list effective view] -> [paired nodes shown]
[nodes list]   -> [prefer node.list effective view]
               -> [fallback to node.pair.list when needed]
               -> [consistent human output + compatible JSON output]

@greptile-apps

greptile-apps Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the source-of-truth mismatch between nodes list and nodes status by making nodes list prefer node.list (the effective paired-node view) over the raw node.pair.list store, with a graceful fallback for older gateways or missing-scope errors. The --json output is separately mapped to preserve full pairing metadata (token, bins, createdAtMs) for backward compatibility.

Confidence Score: 5/5

Safe to merge — both findings are P2 style/edge-case concerns that don't block the primary fix.

No P0/P1 issues found. The logic is sound and consistent with the existing nodes status pattern. The "unauthorized" fallback breadth is a minor edge-case risk (P2), and the duplicated if/else call pattern is a readability issue (P2). New tests cover the three key regression scenarios.

src/cli/nodes-cli/register.status.ts — the canFallbackToPairingList function and the if/else node.list call structure.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/cli/nodes-cli/register.status.ts
Line: 114-125

Comment:
**`"unauthorized"` fallback check is not method-scoped**

`message.includes("unauthorized")` will match any error that contains the word — including a fully-expired or revoked session token. If the gateway returns a generic `"Unauthorized"` for `node.list` for reasons unrelated to scope (e.g., session expiry, some other transient auth rejection), the command silently falls back to `node.pair.list` data and renders it as if it were valid, with no error shown to the user.

The `"missing scope: ..."` branch is precise. The method-not-found branch is also scoped (`message.includes("node.list") && ...`). Making the `"unauthorized"` branch similarly explicit — e.g., requiring `"scope"` or `"node.list"` to co-appear — would reduce the risk of silently swallowing a real auth failure.

```suggestion
function canFallbackToPairingList(err: unknown): boolean {
  const message = normalizeLowercaseStringOrEmpty(formatErrorMessage(err));
  return (
    message.includes("missing scope") ||
    (message.includes("unauthorized") &&
      (message.includes("scope") || message.includes("node.list"))) ||
    (message.includes("node.list") &&
      (message.includes("unknown method") ||
        message.includes("method not found") ||
        message.includes("not implemented") ||
        message.includes("unsupported")))
  );
}
```

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: 349-360

Comment:
**Duplicate `node.list` call in if/else branches**

Both branches call identical `parseNodeList(await callGatewayCli("node.list", opts, {}))` — the only difference is the error-handling policy. This can be collapsed into a single try/catch with the condition inside the catch, removing the duplication and making the policy explicit in one place:

```suggestion
          let knownNodes: NodeListNode[] | null = null;
          try {
            knownNodes = parseNodeList(await callGatewayCli("node.list", opts, {}));
          } catch (err) {
            if (hasFilters || !canFallbackToPairingList(err)) {
              throw err;
            }
          }
```

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

Reviews (1): Last reviewed commit: "CLI: preserve nodes list compatibility c..." | Re-trigger Greptile

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: 5ba24c2b9f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@skainguyen1412

Copy link
Copy Markdown
Contributor Author

The CI/CD failed doesn't related to this PR.

@skainguyen1412

Copy link
Copy Markdown
Contributor Author

Hi @steipete, could you review this PR? Please feel free to raise any issues if you’d like me to make updates

@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex automated review: keeping this open.

Keep open. Current main still has the source-of-truth split this PR targets: nodes status reads the effective node.list catalog, while unfiltered nodes list still renders only node.pair.list. The PR is a plausible focused implementation candidate, and its provided review thread shows the initial bot feedback was addressed by later PR commits.

Best possible solution:

Keep this PR open for maintainer review. The best path is to land this focused CLI fix, or an equivalent change in src/cli/nodes-cli/register.status.ts, so unfiltered openclaw nodes list prefers the effective node.list paired-node view, preserves pending and legacy pairing metadata from node.pair.list, keeps filtered modes strict, and adds command-level regression coverage in src/cli/program.nodes-basic.e2e.test.ts.

What I checked:

  • Current nodes status source: openclaw nodes status calls node.list and renders counts from parseNodeList, so status uses the effective known-node catalog. (src/cli/nodes-cli/register.status.ts:125, 9626ef274ae2)
  • Current nodes list source split: openclaw nodes list first calls node.pair.list; node.list is only called when --connected or --last-connected is active, so the unfiltered command can still show Paired: 0 when the effective paired node only exists in node.list. (src/cli/nodes-cli/register.status.ts:325, 9626ef274ae2)
  • Gateway effective node catalog: The gateway node.list method merges device pairing, legacy node pairing, and connected registry state via createKnownNodeCatalog, then returns listKnownNodes; this is the effective view the PR wants nodes list to prefer. (src/gateway/server-methods/nodes.ts:707, 9626ef274ae2)
  • Effective paired flag: createKnownNodeCatalog includes device-paired IDs, node-paired IDs, and live IDs, and buildEffectiveKnownNode marks paired true when either pairing source exists. (src/gateway/node-catalog.ts:118, 9626ef274ae2)
  • Current CLI test gap: Current CLI node tests cover nodes list --connected and nodes status, but there is no current-main regression test for unfiltered nodes list using node.list as the effective paired source while preserving node.pair.list metadata. (src/cli/program.nodes-basic.e2e.test.ts:65, 9626ef274ae2)
  • Docs confirm separate stores: The nodes docs say nodes status marks a node paired from device pairing role, while node.pair.* is a separate gateway-owned node pairing store. That matches the reported mismatch when CLI list relies only on node.pair.list. Public docs: docs/nodes/index.md. (docs/nodes/index.md:48, 9626ef274ae2)

Remaining risk / open question:

  • The PR still needs normal maintainer review and CI validation, especially around nodes list --json compatibility and fallback behavior for older or lower-scope gateways.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 9626ef274ae2.

@vincentkoc

Copy link
Copy Markdown
Member

ProjectClownfish could not safely update this branch, so it opened a narrow replacement PR instead.

Replacement PR: #72619
Source PR: #65772
Contributor credit is preserved in the replacement PR body and changelog plan.

@vincentkoc vincentkoc closed this Apr 27, 2026
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]: openclaw nodes status and openclaw nodes list does not sync

2 participants