Composio TS SDK: ZodError "Expected object, received null" when tool call fails
Using the Composio TypeScript SDK version 0.1.55, a failing
composio.tools.execute()call throws a ZodError: "Expected object, received null" at thedatapath. The API returnsdata: nullon failed tool calls, but the SDK schema expects an object. Is this a known bug, and was it fixed?Originally asked on GitHub: https://github.com/ComposioHQ/composio/issues/2059
3 answers
Fixed: a Composio maintainer confirmed on 2025-10-16 that the issue was fixed. The thread does not state which SDK release contains the fix, so check the Composio SDK changelog/releases for the version that includes it. No workaround is given in the thread.
The root cause is in the SDK, not in your code. When a tool call fails, the Composio API returns
"data": nullin the response; the SDK's Zod schema expectsdatato be an object, so validation fails and throws aZodError(invalid_type, expected"object", received"null", path["data"]) before you can handle the failure result.Reproduction from the thread (SDK 0.1.55):
jsimport { Composio } from "@composio/core"; const composio = new Composio({ apiKey: "<api-key>" }); const res = await composio.tools.execute("HUBSPOT_GET_PRODUCT", { userId: "default", arguments: {}, });Another user independently confirmed the same behavior: the error occurs when the tool call fails and the API returns
"data": nullinstead of{}. The only action reported by the maintainer is that the fix was completed; keep an eye on new SDK releases that include it.Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Reproduced with SDK 0.1.55 by calling
composio.tools.execute("HUBSPOT_GET_PRODUCT", { userId: "default", arguments: {} }). A failed tool call made the API return"data": null, and the SDK threw a ZodError (invalid_type, expected object, received null, path["data"]).Source: https://github.com/ComposioHQ/composio/issues/2059 (opens external site)
Did this work for you?What @Arunkumar-Dhanraj tried on GitHub (Outcome unclear)
Another user confirmed the same behavior: the error happens when the tool call fails and the API returns
"data": nullinstead of{}.Source: https://github.com/ComposioHQ/composio/issues/2059#issuecomment-3396084685 (opens external site)
Did this work for you?
Related questions
- Does Composio support self-hosting / on-prem deployment?
- Composio initiateConnection error: Cannot read properties of null (reading 'join')
- How to fix ImportError: cannot import name 'Action' from 'composio'?
- Composio TS SDK v3: Zod error 'api_key should be a string, but you provided a undefined'
- Can I use Composio in a commercial app? Terms of use ambiguity