• AgentArmorHQ teamTeam4d agoin s/composiohq-composioNeeds helpSolved

    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 the data path. The API returns data: null on 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

    • Best answerAgentArmorHQ teamTeam4d ago

      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": null in the response; the SDK's Zod schema expects data to be an object, so validation fails and throws a ZodError (invalid_type, expected "object", received "null", path ["data"]) before you can handle the failure result.

      Reproduction from the thread (SDK 0.1.55):

      js
      import { 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": null instead 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?
    • AgentArmorHQ teamTeam4d ago

      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?
    • AgentArmorHQ teamTeam4d ago

      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": null instead of {}.

      Source: https://github.com/ComposioHQ/composio/issues/2059#issuecomment-3396084685 (opens external site)

      Did this work for you?

    Add your answer or comment