Skip to content

fix(cli): align nodes list with nodes status by using node.list as primary source - #51051

Closed
tomi-claycosmos wants to merge 2 commits into
openclaw:mainfrom
tomi-claycosmos:fix/nodes-list-inconsistency
Closed

tomi-claycosmos wants to merge 2 commits into
openclaw:mainfrom
tomi-claycosmos:fix/nodes-list-inconsistency

Conversation

@tomi-claycosmos

Copy link
Copy Markdown

Summary

In k8s/Docker environments, openclaw nodes list shows "Paired: 0" while openclaw nodes status correctly shows the paired node. Both commands should be consistent.

Root Cause

  • nodes list calls node.pair.list (pairing registry) → returns empty in k8s (volume not shared)
  • nodes status calls node.list (gateway live state) → returns all known nodes correctly

Fix

  1. nodes list now calls both node.list (primary) and node.pair.list (secondary/enrichment) in parallel via Promise.all
  2. Shows nodes from node.list that have paired=true OR appear in the pairing registry
  3. lastConnectedAtMs enriched from node.pair.list data when available
  4. Falls back to node.list.connectedAtMs when pairing registry is empty

This makes nodes list and nodes status show consistent results regardless of whether the pairing store is available.

Testing

  • nodes list now shows the same nodes as nodes status in k8s
  • nodes list --connected still filters correctly
  • nodes list --last-connected 24h still filters correctly
  • Pending pairing requests still displayed when present

Issue

Fixes #50847

…nfig exists

When a user sets models.primary = "ollama/..." without running the
provider setup wizard, the provider config entry does not exist in
models.providers. The previous resolveSyntheticLocalProviderAuth()
returned null early because providerConfig was undefined, causing the
auth resolver to throw "No API key found for provider ollama".

This regression (v2026.3.13) made it impossible to use Ollama local
models via direct config without interactive setup.

Fix: check for known local providers (ollama) at the top of the
function, before resolving providerConfig. For ollama, return synthetic
auth regardless of config state.

Fixes: openclaw#50759
@tomi-claycosmos
tomi-claycosmos requested a review from a team as a code owner March 20, 2026 13:04
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes agents Agent runtime and tooling size: S labels Mar 20, 2026

@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

https://github.com/openclaw/openclaw/blob/4afac08ef5aa19769a0e335113f3af0d26fc3529/src/cli/nodes-cli/register.status.ts#L369-L371
P2 Badge Preserve paired-node fields in nodes list --json

Because filteredPaired now contains NodeListNode objects from node.list, the JSON branch no longer emits the paired-node fields that node.pair.list previously exposed (token, createdAtMs, approvedAtMs, lastConnectedAtMs; see src/shared/node-list-types.ts). Any automation consuming openclaw nodes list --json for approval metadata or reconnect timestamps will silently lose those fields after this change even though pairingResult is still fetched.

ℹ️ 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 Outdated
Comment on lines +329 to +333
const filteredPaired = allNodes.filter((node) => {
// Show nodes that are paired (from node.list paired flag)
// OR that appear in the pairing registry
if (!node.paired && !pairedById.has(node.nodeId)) {
return false;

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 Include node.pair approvals when listing paired nodes

This now builds the paired table only from allNodes returned by node.list, but openclaw nodes approve still writes the separate gateway-owned node-pairing store (approveNodePairing in src/infra/node-pairing.ts) while node.list is populated from device pairing via listDevicePairing() in src/gateway/server-methods/nodes.ts:655. In setups that use node.pair.* without a matching device-pair entry, a request can be approved successfully and then never appear under nodes list, so the command no longer reflects the state managed by nodes pending/approve/reject.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a real inconsistency in k8s/Docker environments where openclaw nodes list showed "Paired: 0" while openclaw nodes status correctly showed paired nodes. The fix makes nodes list call both node.list (live gateway, primary) and node.pair.list (pairing registry, enrichment) in parallel, using the union of both sources to determine which nodes are paired. The model-auth.ts change independently fixes Ollama synthetic auth for users who set models.primary to Ollama without running the provider setup wizard.

Key concerns:

  • Breaking --json output schema: The paired array in openclaw nodes list --json now contains NodeListNode objects instead of PairedNode objects. Fields like lastConnectedAtMs, createdAtMs, approvedAtMs, and token are no longer present; connectedAtMs, connected, caps, commands, and paired are new. Scripts consuming this JSON output will silently break.
  • parsePairingList(pairingResult) is called twice — once for pending and again for building pairedById. These can be combined into one destructuring call.
  • The live variable in the pairedRows.map() block (line 390) is dead code — connectedById maps allNodes by nodeId, and since filteredPaired is a subset of allNodes, connectedById.get(n.nodeId) always returns n itself, and the variable is never referenced in the row object.

Confidence Score: 3/5

  • Safe to merge for the k8s consistency fix, but the --json output schema change in nodes list should be confirmed as intentional before merging.
  • The core logic change is sound and fixes a real issue. However, the --json output for nodes list changes type from PairedNode[] to NodeListNode[] for the paired field — this removes fields like lastConnectedAtMs, createdAtMs, approvedAtMs, and token that consumers may depend on. If this is intentional and no downstream automation depends on the old schema, the change is fine. The model-auth.ts change is straightforward and low-risk.
  • src/cli/nodes-cli/register.status.ts — verify the --json output schema change is intentional and acceptable.

Comments Outside Diff (1)

  1. src/cli/nodes-cli/register.status.ts, line 369-373 (link)

    P1 Breaking change in --json output schema

    The paired field in the --json output now contains NodeListNode[] objects instead of the previous PairedNode[] objects. This is a schema-breaking change for any automation or scripts consuming openclaw nodes list --json.

    Key differences that will silently break consumers:

    • PairedNode.lastConnectedAtMs → gone (replaced by NodeListNode.connectedAtMs)
    • PairedNode.createdAtMs and PairedNode.approvedAtMs → gone entirely
    • PairedNode.token → gone entirely
    • New fields added: connected, caps, commands, deviceFamily, modelIdentifier, pathEnv, paired

    If this format change is intentional (aligning nodes list --json with nodes status --json), it should be called out explicitly in the PR as a breaking change to the CLI's JSON output contract.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/cli/nodes-cli/register.status.ts
    Line: 369-373
    
    Comment:
    **Breaking change in `--json` output schema**
    
    The `paired` field in the `--json` output now contains `NodeListNode[]` objects instead of the previous `PairedNode[]` objects. This is a schema-breaking change for any automation or scripts consuming `openclaw nodes list --json`.
    
    Key differences that will silently break consumers:
    - `PairedNode.lastConnectedAtMs` → gone (replaced by `NodeListNode.connectedAtMs`)
    - `PairedNode.createdAtMs` and `PairedNode.approvedAtMs` → gone entirely
    - `PairedNode.token` → gone entirely
    - New fields added: `connected`, `caps`, `commands`, `deviceFamily`, `modelIdentifier`, `pathEnv`, `paired`
    
    If this format change is intentional (aligning `nodes list --json` with `nodes status --json`), it should be called out explicitly in the PR as a breaking change to the CLI's JSON output contract.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/cli/nodes-cli/register.status.ts
Line: 369-373

Comment:
**Breaking change in `--json` output schema**

The `paired` field in the `--json` output now contains `NodeListNode[]` objects instead of the previous `PairedNode[]` objects. This is a schema-breaking change for any automation or scripts consuming `openclaw nodes list --json`.

Key differences that will silently break consumers:
- `PairedNode.lastConnectedAtMs` → gone (replaced by `NodeListNode.connectedAtMs`)
- `PairedNode.createdAtMs` and `PairedNode.approvedAtMs` → gone entirely
- `PairedNode.token` → gone entirely
- New fields added: `connected`, `caps`, `commands`, `deviceFamily`, `modelIdentifier`, `pathEnv`, `paired`

If this format change is intentional (aligning `nodes list --json` with `nodes status --json`), it should be called out explicitly in the PR as a breaking change to the CLI's JSON output contract.

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: 316-321

Comment:
**`parsePairingList` called twice on the same data**

`parsePairingList(pairingResult)` is called on line 316 to destructure `pending`, and then called again on line 320 to build `pairedById`. This double-parses the same result unnecessarily. Combine them into one call:

```suggestion
          const { pending, paired: pairedList } = parsePairingList(pairingResult);
          const allNodes = parseNodeList(nodeListResult);
          // Build a map of PairedNode data keyed by nodeId for lastConnectedAtMs enrichment
          const pairedById = new Map(
            pairedList.map((n) => [n.nodeId, n]),
          );
```

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: 389-391

Comment:
**Dead code: `live` variable is always identical to `n`**

`connectedById` is built from `allNodes` (`new Map(allNodes.map((node) => [node.nodeId, node]))`), and `filteredPaired` is a subset of `allNodes`. Therefore `connectedById.get(n.nodeId)` will always return `n` itself. The `live` variable is also never actually used in the row construction — `pairedData` has taken over for `lastConnectedAtMs`. This variable can be removed entirely:

```suggestion
            const pairedRows = filteredPaired.map((n) => {
              const pairedData = pairedById.get(n.nodeId);
```

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/agents/model-auth.ts
Line: 170-180

Comment:
**Ollama now bypasses explicit `auth` override in provider config**

By moving the Ollama check before `resolveProviderConfig` and `resolveProviderAuthOverride`, this now returns the synthetic key even if the user has explicitly set an `auth` override (e.g. `"token"` or `"oauth"`) in their `models.providers.ollama` config. The old code respected that override by running the Ollama check only after the `authOverride !== "api-key"` guard.

In practice this is unlikely to matter (no one would configure Ollama with OAuth/token auth), and the comment correctly describes the intent. But if the goal is to handle *only* the "no explicit config entry at all" case, an explicit `cfg` null-check guard would make the intent clearer and avoid the silent bypass.

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

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

Comment thread src/cli/nodes-cli/register.status.ts Outdated
Comment on lines +316 to +321
const { pending } = parsePairingList(pairingResult);
const allNodes = parseNodeList(nodeListResult);
// Build a map of PairedNode data keyed by nodeId for lastConnectedAtMs enrichment
const pairedById = new Map(
parsePairingList(pairingResult).paired.map((n) => [n.nodeId, n]),
);

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 parsePairingList called twice on the same data

parsePairingList(pairingResult) is called on line 316 to destructure pending, and then called again on line 320 to build pairedById. This double-parses the same result unnecessarily. Combine them into one call:

Suggested change
const { pending } = parsePairingList(pairingResult);
const allNodes = parseNodeList(nodeListResult);
// Build a map of PairedNode data keyed by nodeId for lastConnectedAtMs enrichment
const pairedById = new Map(
parsePairingList(pairingResult).paired.map((n) => [n.nodeId, n]),
);
const { pending, paired: pairedList } = parsePairingList(pairingResult);
const allNodes = parseNodeList(nodeListResult);
// Build a map of PairedNode data keyed by nodeId for lastConnectedAtMs enrichment
const pairedById = new Map(
pairedList.map((n) => [n.nodeId, n]),
);
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/nodes-cli/register.status.ts
Line: 316-321

Comment:
**`parsePairingList` called twice on the same data**

`parsePairingList(pairingResult)` is called on line 316 to destructure `pending`, and then called again on line 320 to build `pairedById`. This double-parses the same result unnecessarily. Combine them into one call:

```suggestion
          const { pending, paired: pairedList } = parsePairingList(pairingResult);
          const allNodes = parseNodeList(nodeListResult);
          // Build a map of PairedNode data keyed by nodeId for lastConnectedAtMs enrichment
          const pairedById = new Map(
            pairedList.map((n) => [n.nodeId, n]),
          );
```

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

Comment thread src/cli/nodes-cli/register.status.ts Outdated
Comment on lines +389 to +391
const pairedRows = filteredPaired.map((n) => {
const live = connectedById?.get(n.nodeId);
const pairedData = pairedById.get(n.nodeId);

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 Dead code: live variable is always identical to n

connectedById is built from allNodes (new Map(allNodes.map((node) => [node.nodeId, node]))), and filteredPaired is a subset of allNodes. Therefore connectedById.get(n.nodeId) will always return n itself. The live variable is also never actually used in the row construction — pairedData has taken over for lastConnectedAtMs. This variable can be removed entirely:

Suggested change
const pairedRows = filteredPaired.map((n) => {
const live = connectedById?.get(n.nodeId);
const pairedData = pairedById.get(n.nodeId);
const pairedRows = filteredPaired.map((n) => {
const pairedData = pairedById.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: 389-391

Comment:
**Dead code: `live` variable is always identical to `n`**

`connectedById` is built from `allNodes` (`new Map(allNodes.map((node) => [node.nodeId, node]))`), and `filteredPaired` is a subset of `allNodes`. Therefore `connectedById.get(n.nodeId)` will always return `n` itself. The `live` variable is also never actually used in the row construction — `pairedData` has taken over for `lastConnectedAtMs`. This variable can be removed entirely:

```suggestion
            const pairedRows = filteredPaired.map((n) => {
              const pairedData = pairedById.get(n.nodeId);
```

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

Comment thread src/agents/model-auth.ts
Comment on lines +170 to +180
// Check for known local providers first — these should always get synthetic auth,
// even when the user sets models.primary without running the provider setup wizard
// (i.e., no explicit models.providers.{name} config entry exists).
const normalizedProvider = normalizeProviderId(params.provider);
if (normalizedProvider === "ollama") {
return {
apiKey: OLLAMA_LOCAL_AUTH_MARKER,
source: "models.providers.ollama (synthetic local key)",
mode: "api-key",
};
}

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 Ollama now bypasses explicit auth override in provider config

By moving the Ollama check before resolveProviderConfig and resolveProviderAuthOverride, this now returns the synthetic key even if the user has explicitly set an auth override (e.g. "token" or "oauth") in their models.providers.ollama config. The old code respected that override by running the Ollama check only after the authOverride !== "api-key" guard.

In practice this is unlikely to matter (no one would configure Ollama with OAuth/token auth), and the comment correctly describes the intent. But if the goal is to handle only the "no explicit config entry at all" case, an explicit cfg null-check guard would make the intent clearer and avoid the silent bypass.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/model-auth.ts
Line: 170-180

Comment:
**Ollama now bypasses explicit `auth` override in provider config**

By moving the Ollama check before `resolveProviderConfig` and `resolveProviderAuthOverride`, this now returns the synthetic key even if the user has explicitly set an `auth` override (e.g. `"token"` or `"oauth"`) in their `models.providers.ollama` config. The old code respected that override by running the Ollama check only after the `authOverride !== "api-key"` guard.

In practice this is unlikely to matter (no one would configure Ollama with OAuth/token auth), and the comment correctly describes the intent. But if the goal is to handle *only* the "no explicit config entry at all" case, an explicit `cfg` null-check guard would make the intent clearer and avoid the silent bypass.

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

…ing store inconsistency

`nodes list` called node.pair.list as the primary data source, which
returns an empty result in environments where the pairing store (file/DB)
is not shared between the gateway and the node host (e.g. k8s volumes,
Docker). This caused `nodes list` to show 'Paired: 0' while
`nodes status` (which calls node.list) correctly showed the paired node.

Fix: make `nodes list` use node.list as the authoritative source and
node.pair.list as a secondary enrichment source. This aligns both
commands to show consistent results regardless of pairing store availability.

Fixes: openclaw#50847
@tomi-claycosmos
tomi-claycosmos force-pushed the fix/nodes-list-inconsistency branch from 4afac08 to 6f42fb1 Compare March 20, 2026 14:26

@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: 6f42fb105f

ℹ️ 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 on lines +312 to +315
const [nodeListResult, pairingResult] = await Promise.all([
callGatewayCli("node.list", opts, {}),
callGatewayCli("node.pair.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 Keep nodes list usable with pairing-scoped tokens

Calling both RPCs unconditionally here raises the required scope for plain openclaw nodes list: node.pair.list is in the pairing scope, but node.list is read-scoped in src/gateway/method-scopes.ts. Before this change the unfiltered command could run with a pairing-only token because it only needed node.pair.list; now those operators get a hard node.list authorization failure even when they are only reviewing pending/paired nodes.

Useful? React with 👍 / 👎.

Comment thread src/agents/model-auth.ts
Comment on lines +174 to +178
if (normalizedProvider === "ollama") {
return {
apiKey: OLLAMA_LOCAL_AUTH_MARKER,
source: "models.providers.ollama (synthetic local key)",
mode: "api-key",

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 Honor non-API-key auth overrides for Ollama

This early return bypasses the later authOverride !== "api-key" guard, so models.providers.ollama.auth = "token" or "oauth" no longer prevents synthetic local auth. In remote Ollama/proxy setups that intentionally require bearer credentials, a missing token now resolves to ollama-local instead of surfacing an auth error, and downstream callers in src/agents/ollama-stream.ts and src/memory/embeddings-ollama.ts will send Authorization: Bearer ollama-local, which breaks those requests with a misleading credential.

Useful? React with 👍 / 👎.

@tomi-claycosmos

Copy link
Copy Markdown
Author

Noted. Will address all points: (1) merge duplicate parsePairingList calls, (2) remove the dead live variable, (3) review scope requirement vs nodes status use case to avoid unnecessary scope inflation.

@vincentkoc

Copy link
Copy Markdown
Member

Thanks @tomi-claycosmos for working on this. I am closing this PR as superseded because #72619 has now landed the same nodes list/status fix path with the compatibility safeguards and regression coverage required for the canonical issue #46871.

ProjectClownfish could not safely use this branch as the landing path because it mixes the nodes-list change with an unrelated src/agents/model-auth.ts change and still had unresolved review-bot blockers around pairing-scoped tokens and Ollama auth overrides. Your source PR remains useful context and attribution for this fix family. If there is a narrower remaining issue after #72619, please open a fresh PR or comment and we can split it back out.

@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

agents Agent runtime and tooling 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

3 participants