composio icon indicating copy to clipboard operation
composio copied to clipboard

Bug: zod-to-json-schema import fails in CommonJS bundle (v0.2.6)

Open pontus-devoteam opened this issue 1 month ago • 1 comments

Bug Description

The @composio/[email protected] package has a bug in its CommonJS bundle where zod-to-json-schema is imported incorrectly, causing a runtime error when trying to use createCustomTool.

Error

TypeError: (0 , import_zod_to_json_schema.default) is not a function
    at CustomTools.createTool (/opt/nodejs/node_modules/@composio/core/dist/index.cjs:2131:64)

Root Cause

In /node_modules/@composio/core/dist/index.cjs line 927:

var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"), 1);

The __toESM helper is not correctly handling the CommonJS export from [email protected].

Affected Versions

Workaround

Replace line 927 with:

var import_zod_to_json_schema = { default: require("zod-to-json-schema").zodToJsonSchema };

Expected Behavior

The createCustomTool method should work without manual patching of the bundled code.

Environment

  • Runtime: AWS Lambda (Node.js 20.x)
  • Package manager: npm
  • Installation: npm install @composio/[email protected] --omit=dev

Suggested Fix

Update the bundler configuration to correctly handle the zod-to-json-schema CommonJS export, or explicitly import the named export zodToJsonSchema instead of using default import.

pontus-devoteam avatar Nov 29 '25 09:11 pontus-devoteam

Hey @pontus-devoteam, could you share a snippet where we can reproduce this issue?

Uday-sidagana avatar Nov 29 '25 10:11 Uday-sidagana

Thanks for opening this issue. Looks like this may be an instance of a known tsup issue: https://github.com/egoist/tsup/issues/596

jkomyno avatar Dec 03 '25 21:12 jkomyno