Skip to content

normalizeNpmViewMetadata fails on array input from 'npm view --json', breaking all plugin updates #107222

Closed

Description

@foxrainhy

Bug

openclaw plugins update and openclaw update repair fail with:

npm view produced incomplete package metadata

for every npm-source plugin, even when the plugin is at the latest version on npm. After openclaw update runs, all npm plugins get auto-disabled because their update check returns this error.

Reproduction

OpenClaw 2026.7.1. From the user's shell:

$ npm view @openclaw/deepseek-provider name version dist.integrity dist.shasum openclaw --json
[
  {
    "name": "@openclaw/deepseek-provider",
    "version": "2026.7.1",
    "dist.integrity": "sha512-...",
    "dist.shasum": "...",
    "openclaw": { "..." }
  }
]
# ^-- always returns an array, even for a single spec

$ openclaw plugins update deepseek
Could not check deepseek before update; falling back to installer path: npm view produced incomplete package metadata
Failed to update deepseek: npm view produced incomplete package metadata

Root cause

dist/install-source-utils-Bwqp8YNg.js → normalizeNpmViewMetadata(value):

function normalizeNpmViewMetadata(value) {
  if (!value || typeof value !== "object") return null;
  const rec = value;                                  // BUG: value is an array
  const name = normalizeOptionalString(rec.name);     // always undefined
  const version = normalizeOptionalString(rec.version);
  const dist = rec.dist && typeof rec.dist === "object" ? rec.dist : {};
  return {
    name,                                              // undefined
    version,                                           // undefined
    resolvedSpec,
    integrity: normalizeOptionalString(rec["dist.integrity"]) ?? normalizeOptionalString(dist.integrity),
    shasum: normalizeOptionalString(rec["dist.shasum"]) ?? normalizeOptionalString(dist.shasum),
    ...isRecord(rec.openclaw) ? { packageOpenClaw: rec.openclaw } : {}
  };                                                   // → { name: undefined, version: undefined, ... }
}

npm view --json always returns an array [{...}] (per npm's documented JSON output). The current code reads name/version/dist directly off the array object, so every field is undefined. The subsequent check !metadata?.name || !metadata.version is always true → error: "npm view produced incomplete package metadata".

Suggested fix

function normalizeNpmViewMetadata(value) {
  if (!value || typeof value !== "object") return null;
  // npm view --json always returns an array, even for a single spec.
  // Unwrap before inspecting fields.
  let rec = value;
  if (Array.isArray(value)) {
    if (value.length === 0 || value[0] == null || typeof value[0] !== "object") return null;
    rec = value[0];
  }
  const name = normalizeOptionalString(rec.name);
  const version = normalizeOptionalString(rec.version);
  // ... rest unchanged ...
}

Confirmed working patch

I applied this patch locally on 2026.7.1 and openclaw plugins update deepseek firecrawl llama-cpp openclaw-weixin now succeeds with the message: deepseek is up to date (2026.7.1-beta.2).

Impact

  • Every openclaw plugins update
  • Every openclaw update repair
  • Every openclaw plugins install <npm-package>
  • Every openclaw update (because it auto-runs update on installed plugins)

is broken on 2026.7.1 for any npm-source plugin. Affected plugins get auto-disabled, which then blocks openclaw plugins enable with blocked by allowlist if the plugin isn't in plugins.allow (related issue filed separately). The combination of these bugs breaks the entire upgrade path: gateway cannot be re-enabled without manually editing SQLite + allowlist.

Environment

  • OpenClaw 2026.7.1 (2d2ddc4)
  • Node v24.15.0
  • npm 11.6.2
  • Linux (WSL Ubuntu 24.04)

Activity

  1. clawsweeper commented on Jul 14, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 14, 2026, 8:06 AM ET / 12:06 UTC.

    Summary
    Keep open: the released plugin lifecycle has a concrete shared-boundary regression, and current main still lacks evidence that array-shaped npm view --json results are normalized. The two related upgrade reports describe separate failures and do not supersede this fix.

    Reproducibility: yes. for v2026.7.1: the report provides concrete npm and OpenClaw commands, observed output, and a successful local patch. Current-main execution was not independently run, but the failing path remains directly reproducible from source inspection.

    Root-cause cluster
    Relationship: canonical
    Canonical: #107222
    Summary: This issue is canonical for npm metadata array normalization; the two cross-referenced upgrade failures are distinct regressions that compound the same user journey.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    The regression has a narrow shared resolver boundary, concrete released reproduction, clear tests, and no product or security decision blocker.

    Review details

    Best possible solution:

    Normalize both record and single-record array responses in the shared source resolver, reject malformed or ambiguous arrays, and add focused regression coverage for install and update callers without patching generated dist files.

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

    Yes for v2026.7.1: the report provides concrete npm and OpenClaw commands, observed output, and a successful local patch. Current-main execution was not independently run, but the failing path remains directly reproducible from source inspection.

    Is this the best way to solve the issue?

    Yes, with one refinement: fix the shared source normalizer rather than generated dist output, preserving object responses while accepting only valid single-record arrays and adding regression tests.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The exact npm output shape can vary by npm version and query form, so the repair must retain object support and explicitly handle empty, malformed, and ambiguous multi-record arrays.
    • The separate allowlist and startup-checkpoint regressions may continue to block the full upgrade path after this metadata defect is fixed.

    Codex review notes: model internal, reasoning high; reviewed against af9333975262.

    Label changes

    Label changes:

    • add P0: The latest released update and plugin setup paths can disable or prevent installation of npm-source plugins, leaving ordinary users without an in-product recovery path.
    • add impact:ux-release-blocker: Recovering affected plugins currently requires source patching or other technical intervention rather than a supported update, repair, or setup flow.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P0: The latest released update and plugin setup paths can disable or prevent installation of npm-source plugins, leaving ordinary users without an in-product recovery path.
    • impact:ux-release-blocker: Recovering affected plugins currently requires source patching or other technical intervention rather than a supported update, repair, or setup flow.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/infra/install-source-utils.test.ts
    • node scripts/run-vitest.mjs src/plugins/update.test.ts
    • node scripts/run-vitest.mjs src/cli/update-cli.test.ts
    • node scripts/check-changed.mjs -- src/infra/install-source-utils.ts src/infra/install-source-utils.test.ts src/plugins/update.test.ts src/cli/update-cli.test.ts
    • git diff --check

    What I checked:

    Likely related people:

    • wenbo: Authored the merged npm metadata resolver and plugin update hardening work that introduced the affected normalization boundary. (role: introduced behavior; confidence: high; commits: 0da04d78e4a4; files: src/infra/install-source-utils.ts, src/infra/install-source-utils.test.ts, src/plugins/update.ts)
    • steipete: Merged the resolver hardening change and is connected to the current plugin update architecture through that reviewed history. (role: merger and adjacent owner; confidence: medium; commits: 0da04d78e4a4; files: src/infra/install-source-utils.ts, src/plugins/update.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.
    impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.
    no-staleExclude from stale automation
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jul 14, 2026
  3. LeonidasLux commented on Jul 14, 2026

    @LeonidasLux
    Contributor

    Verification complete: fix already landed

    This issue describes the normalizeNpmViewMetadata bug where npm view --json array output (npm 12+) was not unwrapped, causing all plugin update/install operations to fail with npm view produced incomplete package metadata.

    The fix was shipped in PR #102883 (commit 96f0983a85, merged Jul 11, 2026), which added singleton-array unwrapping in normalizeNpmViewMetadata at src/infra/install-source-utils.ts:64-67:

    const entry = Array.isArray(value) && value.length === 1 ? value[0] : value;
    if (!isRecord(entry) || Array.isArray(entry)) {
      return null;
    }
    const rec = entry;

    Verification results (current upstream/main)

    Input Expected Result
    npm 11: single object {...} normalize → fields ✅
    npm 12: singleton array [{...}] unwrap + normalize ✅
    npm 12: multi-version array reject (null) ✅
    npm 12: empty array [] reject (null) ✅
    null / invalid reject (null) ✅

    Test status: 19/19 tests pass on upstream/main.

    Related: PR #106436 extends the fix with state-preservation policy and sibling parseNpmPackageTargetMetadata normalization.

    Suggest closing this issue as already fixed by #102883.

  4. steipete commented on Jul 16, 2026

    @steipete
    Contributor

    Fixed after the stable release.

    The affected v2026.7.1 source reads the npm JSON array as an object at src/infra/install-source-utils.ts:60-78. v2026.7.2-beta.1 includes the singleton-array normalization from #102883 at src/infra/install-source-utils.ts:60-83, which covers the reported one-package response. Current main additionally handles multi-version output safely via #108336, selecting the maximum satisfying version and retaining malformed/range-miss failures as closed errors; focused coverage lives in src/infra/install-source-utils.test.ts.

    Closing as completed. Stable v2026.7.1 remains affected; the fix is available in v2026.7.2-beta.1 and later. Thanks @foxrainhy for the precise reproduction and confirmed patch.

  5. locked as resolved and limited conversation to collaborators on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions