openclaw - ✅(Solved) Fix Slack plugin: test harness leaks vitest into production bundle [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#62949Fetched 2026-04-09 08:00:19
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
0
Timeline (top)
cross-referenced ×3referenced ×2closed ×1commented ×1

Error Message

TypeError: Cannot read properties of undefined (reading 't')

Root Cause

extensions/slack/contract-api.ts line 6:

export { createSlackOutboundPayloadHarness } from "./src/outbound-payload-harness.js";

extensions/slack/src/outbound-payload-harness.ts imports:

import { primeChannelOutboundSendMock } from "openclaw/plugin-sdk/testing";
import { vi } from "vitest";

This is a test-only function exported through a production barrel, causing the bundler to pull vitest into the production build.

Fix Action

Fixed

PR fix notes

PR #62951: fix(slack): remove test harness export from production barrel

Description (problem / solution / changelog)

Summary

  • Remove createSlackOutboundPayloadHarness export from extensions/slack/contract-api.ts
  • Update test files to import directly from the harness source module

Problem

contract-api.ts re-exports createSlackOutboundPayloadHarness, which imports vi from vitest and primeChannelOutboundSendMock from openclaw/plugin-sdk/testing. The bundler follows the import chain and pulls these test-only dependencies into the production dist.

At runtime, vi is undefined and vi.fn() throws:

TypeError: Cannot read properties of undefined (reading 't')

Fix

Remove the test harness from the production barrel. Test files that need it now import directly from ./src/outbound-payload-harness.js:

  • extensions/slack/src/outbound-payload.test.ts
  • test/helpers/channels/outbound-payload-contract.ts

Fixes #62949

Test plan

  • pnpm check passes (lint, typecheck, format)
  • pnpm test — scoped Slack outbound tests still pass
  • pnpm build — verify dist/extensions/slack/contract-api.js no longer imports vitest

Changed files

  • extensions/slack/contract-api.ts (modified, +0/-1)
  • extensions/slack/src/outbound-payload.test.ts (modified, +1/-1)
  • test/helpers/channels/outbound-payload-contract.ts (modified, +1/-1)

PR #63047: fix: remove test harness export from Slack plugin production barrel

Description (problem / solution / changelog)

Summary

Fixes #62949.

Problem

The Slack extension's contract-api.ts re-exported createSlackOutboundPayloadHarness which imports vitest and openclaw/plugin-sdk/testing. The bundler followed the import chain and pulled these test-only dependencies into the production dist, causing a TypeError at runtime when vi is undefined.

Solution

Remove the re-export from the production barrel file. The two test files that consumed it now import directly from the harness module (./src/outbound-payload-harness.js).

Changes

  • extensions/slack/contract-api.ts: Remove createSlackOutboundPayloadHarness export
  • extensions/slack/src/outbound-payload.test.ts: Import from ./outbound-payload-harness.js instead of ../contract-api.js
  • test/helpers/channels/outbound-payload-contract.ts: Import from ../../../extensions/slack/src/outbound-payload-harness.js

Testing

  • Existing tests pass (10/10 across both test suites)
  • No production code changes

<sub>🔧 Generated by issue-to-pr</sub>

Changed files

  • extensions/slack/contract-api.ts (modified, +0/-1)
  • extensions/slack/src/outbound-payload.test.ts (modified, +1/-1)
  • test/helpers/channels/outbound-payload-contract.ts (modified, +1/-1)

PR #63311: fix(plugins): keep test helpers out of contract barrels

Description (problem / solution / changelog)

Summary

  • keep bundled plugin contract barrels runtime-only so test helpers do not leak into production surfaces
  • move Slack and iMessage test-only helpers onto test-api and route shared channel helpers through bundled plugin public/test surface loaders
  • keep the plugin guardrail lightweight while still covering Slack-style harness leaks, make the test-only filenames more explicit, and validate bundled artifact paths stay plugin-local

Changes

  • remove test-helper exports from extensions/slack/contract-api.ts and extensions/imessage/contract-api.ts
  • add/keep test-only exports on extensions/slack/test-api.ts and extensions/imessage/test-api.ts
  • add plugin-level contract barrel guardrails in src/plugins/contracts/plugin-entry-guardrails.test.ts
  • simplify the contract-barrel source scan to TypeScript source extensions actually used by bundled plugin contract barrels
  • remove the redundant Slack-specific channel guard now that the plugin-level guard covers that leak shape
  • update shared channel helpers to use loadBundledPluginTestApiSync(...) / loadBundledPluginPublicSurfaceSync(...) instead of repo-relative extensions/** imports
  • reject bundled plugin artifact paths that are empty, absolute, or traverse outside the plugin root while still allowing valid nested plugin-local paths like src/...
  • rename obvious test-only implementation files to clearer names like outbound-payload.test-harness.ts and imessage.test-plugin.ts

Validation

  • node scripts/run-vitest.mjs run src/plugins/public-surface-runtime.test.ts src/plugins/contracts/plugin-entry-guardrails.test.ts src/channels/plugins/contracts/channel-import-guardrails.test.ts extensions/slack/src/outbound-payload.test.ts extensions/imessage/src/test-plugin.test.ts src/plugin-sdk/facade-loader.test.ts src/plugin-sdk/facade-runtime.test.ts
  • pnpm build:strict-smoke
  • independent verify passes over general, tests, and silent-failure lanes during iteration

Linked Issues

  • Refs #62949
  • Refs #63239

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/imessage/contract-api.ts (modified, +0/-1)
  • extensions/imessage/src/imessage.test-plugin.ts (renamed, +21/-9)
  • extensions/imessage/src/test-plugin.test.ts (modified, +8/-1)
  • extensions/imessage/test-api.ts (added, +1/-0)
  • extensions/slack/contract-api.ts (modified, +0/-1)
  • extensions/slack/src/outbound-payload.test-harness.ts (renamed, +0/-0)
  • extensions/slack/src/outbound-payload.test.ts (modified, +1/-1)
  • extensions/slack/test-api.ts (modified, +1/-0)
  • extensions/whatsapp/contract-api.ts (modified, +0/-6)
  • extensions/whatsapp/src/outbound-base.test.ts (modified, +1/-1)
  • extensions/whatsapp/test-api.ts (modified, +1/-0)
  • src/plugin-sdk/facade-activation-check.runtime.ts (modified, +2/-1)
  • src/plugin-sdk/facade-loader.ts (modified, +6/-2)
  • src/plugin-sdk/facade-runtime.ts (modified, +7/-3)
  • src/plugins/contracts/plugin-entry-guardrails.test.ts (modified, +266/-6)
  • src/plugins/public-surface-runtime.test.ts (added, +32/-0)
  • src/plugins/public-surface-runtime.ts (modified, +28/-4)
  • src/test-utils/bundled-plugin-public-surface.ts (modified, +4/-2)
  • test/helpers/channels/imessage-test-plugin.ts (modified, +19/-1)
  • test/helpers/channels/outbound-payload-contract.ts (modified, +130/-23)

Code Example

import { n as vi } from "../../test.p_J6dB8a-Dc5seVFb.js";
import { A as primeChannelOutboundSendMock } from "../../testing-Bq-x5gN1.js";

---

TypeError: Cannot read properties of undefined (reading 't')

---

export { createSlackOutboundPayloadHarness } from "./src/outbound-payload-harness.js";

---

import { primeChannelOutboundSendMock } from "openclaw/plugin-sdk/testing";
import { vi } from "vitest";
RAW_BUFFERClick to expand / collapse

Bug Description

The Slack extension's contract-api.ts re-exports createSlackOutboundPayloadHarness from ./src/outbound-payload-harness.js, which imports vi from vitest and primeChannelOutboundSendMock from openclaw/plugin-sdk/testing. The bundler follows the import chain and includes these test-only dependencies in the production dist.

Runtime Error

When the Slack plugin loads at runtime, dist/extensions/slack/contract-api.js executes:

import { n as vi } from "../../test.p_J6dB8a-Dc5seVFb.js";
import { A as primeChannelOutboundSendMock } from "../../testing-Bq-x5gN1.js";

Since vitest is not available at runtime, vi is undefined, and calling vi.fn() inside createSlackOutboundPayloadHarness throws:

TypeError: Cannot read properties of undefined (reading 't')

(t is the minified name of fn)

Root Cause

extensions/slack/contract-api.ts line 6:

export { createSlackOutboundPayloadHarness } from "./src/outbound-payload-harness.js";

extensions/slack/src/outbound-payload-harness.ts imports:

import { primeChannelOutboundSendMock } from "openclaw/plugin-sdk/testing";
import { vi } from "vitest";

This is a test-only function exported through a production barrel, causing the bundler to pull vitest into the production build.

Affected Version

v2026.4.7 confirmed. Likely also affects v2026.4.8+ since the source (contract-api.ts) still contains the same export on main.

Impact

  • Severity: Low — the error is non-fatal and does not block Slack plugin functionality
  • Scope: Slack plugin loading logs an error on startup

Suggested Fix

Remove the createSlackOutboundPayloadHarness export from extensions/slack/contract-api.ts. Test files that need it can import directly from ./src/outbound-payload-harness.js:

  • test/helpers/channels/outbound-payload-contract.ts
  • extensions/slack/src/outbound-payload.test.ts

Reproduction

  1. Install openclaw v2026.4.7
  2. Enable the Slack plugin
  3. Observe the TypeError: Cannot read properties of undefined (reading 't') error during startup

extent analysis

TL;DR

Remove the createSlackOutboundPayloadHarness export from extensions/slack/contract-api.ts to prevent including test-only dependencies in the production build.

Guidance

  • Identify and remove any unnecessary exports of test-only functions or variables from production barrels.
  • Update test files to import createSlackOutboundPayloadHarness directly from ./src/outbound-payload-harness.js instead of relying on the removed export.
  • Verify that the production build no longer includes vitest and that the TypeError is resolved.
  • Review other parts of the codebase for similar issues where test-only dependencies might be included in production builds.

Example

// Before
export { createSlackOutboundPayloadHarness } from "./src/outbound-payload-harness.js";

// After
// Remove the above line to prevent including vitest in the production build

Notes

This fix assumes that createSlackOutboundPayloadHarness is only used in test contexts and can be safely removed from the production export. If this function is required for production functionality, an alternative solution will be needed to ensure vitest is not included in the production build.

Recommendation

Apply workaround: Remove the unnecessary export to prevent including test-only dependencies in the production build, as this is a low-severity issue that does not block functionality but does cause an error at startup.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING