{"record":{"id":"26cfbdbcb0bf5042","repo":"ComposioHQ/composio","slug":"invalid-tool-execute-parameters","errorCode":null,"errorMessage":"Invalid tool execute parameters","messagePattern":"Invalid tool execute parameters","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/models/Tools.ts","lineNumber":1068,"sourceCode":"\n    result = await this.applyAfterExecuteModifiers(\n      tool,\n      {\n        toolSlug: slug,\n        toolkitSlug,\n        result,\n      },\n      (modifiers as ExecuteToolModifiers).afterExecute,\n      requestOptions\n    );\n\n    return result;\n  }\n\n  private parseToolExecuteParams(body: ToolExecuteParams): ToolExecuteParams {\n    const executeParams = ToolExecuteParamsSchema.safeParse(body);\n    if (!executeParams.success) {\n      throw new ValidationError('Invalid tool execute parameters', { cause: executeParams.error });\n    }\n    return executeParams.data;\n  }\n\n  /**\n   * Executes a given tool with the provided parameters.\n   *\n   * This method calls the Composio API to execute the tool and returns the response.\n   *\n   * **Version Control:**\n   * By default, manual tool execution requires a specific toolkit version. If the version resolves to \"latest\",\n   * the execution will throw a `ComposioToolVersionRequiredError` unless `dangerouslySkipVersionCheck` is set to `true`.\n   * This helps prevent unexpected behavior when new toolkit versions are released.\n   *\n   * @param {string} slug - The slug/ID of the tool to be executed\n   * @param {ToolExecuteParams} body - The parameters to be passed to the tool\n   * @param {string} [body.version] - The specific version of the tool to execute (e.g., \"20250909_00\")\n   * @param {boolean} [body.dangerouslySkipVersionCheck] - Skip version validation for \"latest\" version (use with caution)","sourceCodeStart":1050,"sourceCodeEnd":1086,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/models/Tools.ts#L1050-L1086","documentation":"ValidationError('Invalid tool execute parameters') is thrown by parseToolExecuteParams when the body fails ToolExecuteParamsSchema.safeParse. This is a client-side Zod guard that fires before any network call; the underlying ZodError is attached as cause and lists exactly which fields failed.","triggerScenarios":"Calling the tool-execution path that routes through parseToolExecuteParams (executeToolFn / executeParams) with a body that violates ToolExecuteParamsSchema — wrong types (arguments not an object, connectedAccountId not a string), missing required fields, or unexpected field shapes.","commonSituations":"Passing a raw LLM-generated JSON string as arguments instead of a parsed object; omitting required fields; snake_case keys copied from API docs (tool_id vs toolId); schema drift after an SDK upgrade tightening constraints.","solutions":["Inspect error.cause (ZodError .issues) to see exactly which paths failed and fix those fields","Ensure arguments is a plain object — JSON.parse strings first — and required fields like toolId are present with correct types","Pre-validate with the exported ToolExecuteParamsSchema in dev/tests to catch shape mismatches before calling execute"],"exampleFix":"// before\nawait tools.execute({ toolId, arguments: '{\"query\": \"hi\"}' }); // string\n\n// after\nawait tools.execute({ toolId, arguments: { query: 'hi' } });","handlingStrategy":"validation","validationCode":"import { ToolExecuteParamsSchema } from '@composio/core';\nconst parsed = ToolExecuteParamsSchema.safeParse(params);\nif (!parsed.success) {\n  throw new Error(parsed.error.issues.map(i => `${i.path}: ${i.message}`).join('; '));\n}","typeGuard":"const isRecord = (v: unknown): v is Record<string, unknown> =>\n  typeof v === 'object' && v !== null && !Array.isArray(v);","tryCatchPattern":"try {\n  await tools.execute(params);\n} catch (e) {\n  if (e instanceof ValidationError) console.error(e.cause?.issues ?? e.cause);\n}","preventionTips":["Parse LLM JSON strings before passing as arguments","Type execute calls against the SDK params so mismatches surface at compile time","Log Zod issue paths on failure instead of only the message"],"tags":["composio","zod","validation","tool-execution","typescript"],"backgroundTag":"schema-validation-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}