Skip to content

fix(plugin-sdk): bundle zod subpath artifact#78464

Closed
zeus1959 wants to merge 1 commit into
openclaw:mainfrom
zeus1959:fix-plugin-sdk-zod-pnpm-global
Closed

fix(plugin-sdk): bundle zod subpath artifact#78464
zeus1959 wants to merge 1 commit into
openclaw:mainfrom
zeus1959:fix-plugin-sdk-zod-pnpm-global

Conversation

@zeus1959

@zeus1959 zeus1959 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: openclaw/plugin-sdk/zod shipped as dist/plugin-sdk/zod.js with a bare runtime export * from "zod", which can fail in pnpm global installs where zod is not resolvable from the OpenClaw package root.
  • Why it matters: bundled and third-party channel plugins import this public SDK subpath during registration, so a missing bare zod dependency can prevent plugins such as Feishu and BlueBubbles from registering.
  • What changed: force zod into the tsdown bundle graph so the published SDK subpath imports only package-local chunks.
  • Guardrail: extend the npm postpublish verifier with a package-artifact check that rejects dist/plugin-sdk/zod.js when it imports or re-exports bare zod.

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)

src/plugin-sdk/zod.ts re-exported from bare zod, and the build did not force that dependency to stay bundled for the public SDK subpath. Published artifacts could therefore contain export * from "zod", which relies on Node resolving zod from the installed OpenClaw package location. pnpm global installs can leave that dependency unavailable from that path.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Package-artifact smoke
  • Target test or file:
    • test/openclaw-npm-postpublish-verify.test.ts
    • scripts/openclaw-npm-postpublish-verify.ts
  • Scenario the test locks in: installed dist/plugin-sdk/zod.js must be self-contained and must not import or re-export bare zod.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Linux workspace
  • Runtime/container: Node v24.15.0, pnpm 10.33.2/10.33.3 via Corepack
  • Integration/channel: package artifact and plugin SDK zod subpath

Steps

  1. Build the package.
  2. Inspect dist/plugin-sdk/zod.js for bare zod imports/exports.
  3. Pack the candidate tarball.
  4. Install it into an isolated pnpm global root.
  5. Import openclaw/plugin-sdk/zod from the installed package.

Expected

The zod SDK subpath imports successfully and the installed artifact verifier reports no bare zod import/export.

Actual

After this patch, the installed pnpm global tarball import succeeded and the verifier returned [].

Evidence

$ pnpm build
OK: All 4 required plugin-sdk exports verified.
[build-all] write-cli-compat

$ rg -n 'from "zod"|from "zod/|export \* from "zod|import\("zod' dist/plugin-sdk/zod.js dist -g '*.js' | head -100
# no output

$ pnpm pack --pack-destination /tmp/openclaw-zod-smoke
Tarball Details
/tmp/openclaw-zod-smoke/openclaw-2026.5.6.tgz

$ PNPM_HOME=/tmp/openclaw-zod-smoke/pnpm-home HOME=/tmp/openclaw-zod-smoke/home PATH=/tmp/openclaw-zod-smoke/pnpm-home:$PATH pnpm install -g /tmp/openclaw-zod-smoke/openclaw-2026.5.6.tgz --global-dir /tmp/openclaw-zod-smoke/global --store-dir /tmp/openclaw-zod-smoke/store --no-lockfile --dangerously-allow-all-builds
/tmp/openclaw-zod-smoke/global/5:
+ openclaw 2026.5.6

$ node --input-type=module --eval "const mod = await import('openclaw/plugin-sdk/zod'); console.log(typeof mod.z.object, typeof mod.object);"
function function

$ node --import tsx --input-type=module --eval "import { collectInstalledPluginSdkZodArtifactErrors } from './scripts/openclaw-npm-postpublish-verify.ts'; const errors = collectInstalledPluginSdkZodArtifactErrors('/tmp/openclaw-zod-smoke/global/5/node_modules/openclaw'); console.log(JSON.stringify(errors));"
[]

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: packaging more zod code into the OpenClaw runtime artifact could increase package size.
    • Mitigation: this only forces an existing root runtime dependency into the bundle graph for a public SDK subpath that must work from installed packages.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 6, 2026
@clawsweeper

clawsweeper Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: #78515 already landed the same zod bundling fix with a stronger reachable-chunk artifact verifier, and that implementation is present in v2026.5.20.

Canonical path: Keep the shipped implementation from #78515 and close this duplicate PR rather than merging a stale parallel branch.

So I’m closing this here and keeping the remaining discussion on #78515.

Review details

Best possible solution:

Keep the shipped implementation from #78515 and close this duplicate PR rather than merging a stale parallel branch.

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

Yes. The linked issue and PR body give a concrete pnpm global install path for the old artifact failure, and source inspection shows the public SDK subpath and package verifier path involved.

Is this the best way to solve the issue?

No for this PR as the landing vehicle. The build-side direction was right, but the already-merged implementation is the better solution because it also verifies reachable local chunks from the zod entry artifact.

Security review:

Security review cleared: The diff only changes bundling for an existing declared dependency plus package-artifact verification, tests, and changelog text; it adds no new dependency source, permissions, network calls, lifecycle hooks, or secret handling.

What I checked:

Likely related people:

  • ggzeng: Authored the detailed linked bug report and the merged superseding PR whose squash commit fixed the packaging issue and shipped in v2026.5.20. (role: canonical fix contributor; confidence: high; commits: ea72414e1c44; files: tsdown.config.ts, scripts/openclaw-npm-postpublish-verify.ts, test/openclaw-npm-postpublish-verify.test.ts)
  • obviyus: Commit 8b13710 added the public plugin-sdk/zod subpath and related package metadata that made this installed-package contract relevant. (role: introduced SDK surface; confidence: high; commits: 8b13710c0921; files: src/plugin-sdk/zod.ts, package.json, scripts/lib/plugin-sdk-entrypoints.json)
  • Takhoffman: Commit 7651a03 added the packed CLI smoke and postpublish verifier infrastructure that the zod artifact guard extends. (role: verifier feature contributor; confidence: medium; commits: 7651a03424fa; files: scripts/openclaw-npm-postpublish-verify.ts, test/openclaw-npm-postpublish-verify.test.ts)
  • altaywtf: The canonical squash commit records altaywtf as reviewer and co-author for the merged zod packaging fix. (role: reviewer and co-author of superseding fix; confidence: medium; commits: ea72414e1c44; files: tsdown.config.ts, scripts/openclaw-npm-postpublish-verify.ts, test/openclaw-npm-postpublish-verify.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8961eae3f022; fix evidence: release v2026.5.20, commit ea72414e1c44.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 14, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@giodl73-repo giodl73-repo removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label May 21, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(plugin-sdk): zod bare import fails to resolve in pnpm global installs

2 participants