Skip to content

fix(plugins): loading no longer crashes on malformed build metadata - #117639

Merged
steipete merged 1 commit into
openclaw:mainfrom
Lucenx9:codex/guard-plugin-build-metadata
Aug 2, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
Lucenx9:codex/guard-plugin-build-metadata

Conversation

@Lucenx9

@Lucenx9 Lucenx9 commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where plugin loading could crash when a plugin package contained a non-string openclaw.build.openclawVersion value.

Why This Change Was Made

Manifest-backed plugin records now read build provenance through the canonical optional-string normalizer. Valid strings remain trimmed, while empty or malformed values are treated as absent. The shared record builder covers both runtime and CLI plugin loaders without changing the documented package metadata contract.

User Impact

Malformed third-party plugin build metadata no longer aborts plugin registry construction. The affected metadata is ignored and normal plugin diagnostics can continue.

Evidence

  • Before the fix, a numeric build version reproduces TypeError: ...openclawVersion?.trim is not a function.
  • Added a focused regression test covering trimmed valid metadata and a malformed numeric value.
  • Canonical normalizer proof passes for both cases.
  • ./node_modules/.bin/oxfmt --check --threads=1 src/plugins/loader-shared.ts src/plugins/loader-shared.test.ts
  • git diff --check upstream/main...HEAD
  • node scripts/docs-list.js
  • Codex autoreview (gpt-5.6-sol, high): clean, no accepted/actionable findings.
  • Focused Vitest was attempted with one worker, but the local macOS runner stalled during startup and ended with ECANCELED after the no-output watchdog. The added regression remains for CI execution; no full local suite was run.

Real loader proof

Executed against the CI-built dist-runtime-build artifact for exact PR head 6bf72ad9a239155315c11f56dd64f2a4ec5f76cf (artifact digest sha256:46323ad6dadd7be00082ba71b0c7a68e39ead4ecd418a83541f6b3e298ece60e). $PROOF_ROOT below is an isolated temporary directory; paths are redacted.

The on-disk plugin fixture contained malformed numeric build provenance:

$ jq '{openclawBuild: .openclaw.build}' "$PROOF_ROOT/fixture/package.json"
{
  "openclawBuild": {
    "openclawVersion": 42
  }
}

The CLI metadata loader completed normally and omitted the malformed provenance:

$ env OPENCLAW_STATE_DIR="$PROOF_ROOT/state" OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 JITI_FS_CACHE=false node "$PROOF_ROOT/runtime/dist/entry.js" plugins inspect malformed-build-proof --json | jq '{plugin: {id: .plugin.id, status: .plugin.status, imported: .plugin.imported, builtWithOpenClawVersionPresent: (.plugin | has("builtWithOpenClawVersion"))}, diagnostics}'
{
  "plugin": {
    "id": "malformed-build-proof",
    "status": "loaded",
    "imported": false,
    "builtWithOpenClawVersionPresent": false
  },
  "diagnostics": []
}

The runtime loader also imported the plugin and completed normally:

$ env OPENCLAW_STATE_DIR="$PROOF_ROOT/state" OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 JITI_FS_CACHE=false node "$PROOF_ROOT/runtime/dist/entry.js" plugins inspect malformed-build-proof --runtime --json | jq '{plugin: {id: .plugin.id, status: .plugin.status, imported: .plugin.imported, builtWithOpenClawVersionPresent: (.plugin | has("builtWithOpenClawVersion"))}, diagnostics}'
{
  "plugin": {
    "id": "malformed-build-proof",
    "status": "loaded",
    "imported": true,
    "builtWithOpenClawVersionPresent": false
  },
  "diagnostics": []
}

Both commands exited 0. This exercises the public plugins inspect command through both loader modes: the malformed metadata no longer crashes registry construction, and the plugin reaches the normal loaded state.

AI Assistance

AI-assisted with Codex. I reviewed the implementation and understand the change.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 6:33 PM ET / 22:33 UTC.

ClawSweeper review

What this changes

The PR makes plugin registry records ignore malformed non-string openclaw.build.openclawVersion metadata instead of crashing, with regression coverage for valid and malformed values.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for normal merge review: current main still calls .trim() directly on untrusted package metadata, while this branch uses the established optional-string normalizer at the shared record-builder boundary. The contributor added terminal proof for both metadata-only and runtime plugin loading; likely related people are wangmiao0668000666 (high confidence) and Peter Steinberger (medium confidence).

Priority: P2
Reviewed head: 6bf72ad9a239155315c11f56dd64f2a4ec5f76cf

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused shared-boundary fix with regression coverage and convincing artifact-backed behavior proof for both affected loader modes.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body contains artifact-backed, redacted terminal output for the exact head showing malformed numeric metadata no longer crashes either public plugin-inspection loader mode and each command exits successfully.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body contains artifact-backed, redacted terminal output for the exact head showing malformed numeric metadata no longer crashes either public plugin-inspection loader mode and each command exits successfully.
Evidence reviewed 6 items Current-main failure point: Current main still directly invokes .trim() on candidate.packageManifest?.build?.openclawVersion, so a numeric value from parsed third-party package metadata can throw before a registry record is created.
Shared-boundary repair: The PR replaces the unsafe call with normalizeOptionalString, whose contract trims strings and returns undefined for non-strings and empty values; this preserves valid metadata while making malformed metadata non-fatal.
Both loader modes share the repaired builder: Runtime candidate loading builds records through the shared helper for both duplicate and normal candidates, so fixing that helper covers the central registry path rather than only one consumer.
Findings None None.
Security None None.

How this fits together

Plugin discovery reads third-party package metadata and turns manifest-backed candidates into registry records used by plugin inspection and runtime activation. That record-building step feeds both lightweight metadata loading and the path that imports a plugin at runtime.

flowchart LR
  A[Third-party plugin package.json] --> B[Plugin discovery]
  B --> C[Manifest-backed candidate]
  C --> D[Shared plugin record builder]
  D --> E[Plugin registry]
  E --> F[CLI plugin inspection]
  E --> G[Runtime plugin activation]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: the proposed change is coherent, has no actionable review finding, and is ready for ordinary maintainer merge review.
Agent review details

Security

None.

PR surface

Source +5, Tests +46. Total +51 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 2 +5
Tests 1 47 1 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 54 3 +51

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/plugins/loader-shared.test.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Merge the shared-boundary normalization and regression test so malformed third-party package metadata is treated as absent without changing the documented valid-string metadata contract.

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

Yes, source establishes a high-confidence path: a numeric openclaw.build.openclawVersion reaches the shared record builder on current main, where optional chaining does not prevent .trim() from being called on a number. The contributor's artifact-backed terminal transcript additionally shows the repaired CLI and runtime paths completing normally.

Is this the best way to solve the issue?

Yes. Normalizing at the shared manifest-record builder is the narrowest maintainable repair because both loader modes consume that record and the repository already provides this exact canonical optional-string contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: A malformed third-party plugin package can currently crash registry construction, but the impact is limited to an uncommon plugin-metadata input and the focused repair is ready for ordinary review.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body contains artifact-backed, redacted terminal output for the exact head showing malformed numeric metadata no longer crashes either public plugin-inspection loader mode and each command exits successfully.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains artifact-backed, redacted terminal output for the exact head showing malformed numeric metadata no longer crashes either public plugin-inspection loader mode and each command exits successfully.

Evidence

What I checked:

  • Current-main failure point: Current main still directly invokes .trim() on candidate.packageManifest?.build?.openclawVersion, so a numeric value from parsed third-party package metadata can throw before a registry record is created. (src/plugins/loader-shared.ts:288, b84d7e3d5476)
  • Shared-boundary repair: The PR replaces the unsafe call with normalizeOptionalString, whose contract trims strings and returns undefined for non-strings and empty values; this preserves valid metadata while making malformed metadata non-fatal. (src/plugins/loader-shared.ts:291, 6bf72ad9a239)
  • Both loader modes share the repaired builder: Runtime candidate loading builds records through the shared helper for both duplicate and normal candidates, so fixing that helper covers the central registry path rather than only one consumer. (src/plugins/loader-runtime-candidate.ts:150, b84d7e3d5476)
  • Focused regression coverage: The added test proves that a whitespace-padded string remains trimmed and that numeric metadata produces no build-version field. (src/plugins/loader-shared.test.ts:53, 6bf72ad9a239)
  • Real behavior proof: The PR body includes redacted terminal output from the CI-built artifact for this exact head: plugins inspect completes with malformed numeric metadata in both normal and --runtime modes, reports the plugin loaded, omits malformed provenance, and exits 0. (6bf72ad9a239)
  • Feature provenance and release state: Blame attributes the current direct metadata read to commit ebb301c32d9e2e1ec61baa783564eb38e4296895; the PR head is not contained in current main, so the requested repair is neither on main nor in the current v2026.7.1 release tag. (src/plugins/loader-shared.ts:288, ebb301c32d9e)

Likely related people:

  • wangmiao0668000666: git blame attributes the direct build-version read at the affected record-builder line to this commit, making this the clearest history connection to the bug boundary. (role: introduced the current metadata-read behavior; confidence: high; commits: ebb301c32d9e; files: src/plugins/loader-shared.ts)
  • Peter Steinberger: Recent file history includes this contributor's refactor commit on the shared loader surface, making them a plausible adjacent reviewer for record-builder ownership. (role: recent loader-history contributor; confidence: medium; commits: bde1602e6e86; files: src/plugins/loader-shared.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-01T21:20:30.374Z sha 6bf72ad :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Maintainer verification on exact contributor head 6bf72ad9a239155315c11f56dd64f2a4ec5f76cf: the shared manifest-record owner now uses the existing canonical optional-string normalizer instead of calling .trim() on untrusted plugin package build metadata.

  • Created eight real on-disk plugin package directories, each with actual package.json, openclaw.plugin.json, and entry module; ran both real loadOpenClawPluginCliRegistry and loadOpenClawPlugins against the directory path—16 discovery/load operations on untouched current main and 16 on the exact PR head. Numeric, object, and array openclaw.build.openclawVersion values crash both current-main loaders with ...trim is not a function; this head loads both registries for all eight inputs. Valid and padded version strings retain 2026.7.2; blank, numeric, object, array, null, and missing values normalize to absent.
  • Ran the real validateExternalCodePluginPackageJson contract for every same package: all malformed/missing values remain rejected for publication; valid/padded values still pass. Traced metadata through CLI backend registration and verified shipped legacy-beta tool enforcement remains fail-closed when provenance is absent; no plugin security or publication contract is relaxed.
  • OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-117639-plugin node scripts/run-vitest.mjs src/plugins/loader-shared.test.ts packages/plugin-package-contract/src/index.test.ts src/agents/cli-backends.test.ts — 3 files, 24 tests passed, including package publication validation and the security-sensitive beta provenance gate.
  • Fresh .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --engine codex --thinking xhigh — Sol xhigh clean (0.99). Exact-head hosted CI 30718731055: success; Workflow Sanity 30718731058: success.

@steipete
steipete merged commit d976f88 into openclaw:main Aug 2, 2026
138 of 152 checks passed
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

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

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants