Skip to content

Slack plugin: test harness leaks vitest into production bundle #62949

@splitCoding

Description

@splitCoding

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions