Skip to content

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

@pontus-devoteam

Description

@pontus-devoteam

Bug Description

The @composio/core@0.2.6 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 zod-to-json-schema@3.25.0.

Affected Versions

  • @composio/core@0.2.6
  • @composio/anthropic@0.2.6
  • zod-to-json-schema@3.25.0

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/core@0.2.6 --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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions