{"record":{"id":"6d5608022790aee5","repo":"n8n-io/n8n","slug":"error-executing-tool-error-as-error-message","errorCode":null,"errorMessage":"Error executing tool: ${(error as Error).message}","messagePattern":"Error executing tool: (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/ToolExecutor/ToolExecutor.node.ts","lineNumber":192,"sourceCode":"\t\t\t\t\t\t\t\t\tmetadata: buildResponseMetadata(response, 0),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst result = await executeTool(toolkitTool, getQueryData(toolName) ?? {});\n\t\t\t\t\t\t\tresultData.push(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Handle single tool\n\t\t\t\t\tif (!toolName || toolName === tool.name) {\n\t\t\t\t\t\tconst toolInput = getQueryData(toolName || tool.name);\n\t\t\t\t\t\tconst result = await executeTool(tool, toolInput ?? {});\n\t\t\t\t\t\tresultData.push(result);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`Error executing tool: ${(error as Error).message}`,\n\t\t\t);\n\t\t}\n\t\treturn [resultData];\n\t}\n}\n","sourceCodeStart":174,"sourceCodeEnd":200,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/ToolExecutor/ToolExecutor.node.ts#L174-L200","documentation":"Catch-all NodeOperationError thrown by the ToolExecutor node when executing the selected tool (single tool or tools within a toolkit) raises any exception. The for-loop over toolInputs and the per-tool executeTool calls are wrapped in try/catch; the catch re-throws with 'Error executing tool: <message>', normalizing arbitrary tool errors into a NodeOperationError.","triggerScenarios":"Any error thrown inside the tool execution loop (toolkit getTools, executeTool, schema conversion, the tool's own run) is caught and re-thrown. Fires when the underlying LangChain tool raises: bad arguments, upstream API failure, zod schema validation failure, permission errors.","commonSituations":"Tool arguments do not match its schema; the tool's backend API rejects the call (auth, rate limit, not found); a custom tool implementation throws; zod validation fails when converting a string input to the tool's ZodObject schema.","solutions":["Read the appended error.message to identify the underlying tool failure.","Ensure the query arguments match the tool's input schema (field names and types).","For API-backed tools, verify credentials, rate limits, and endpoint availability.","Run the tool in isolation with the same arguments to reproduce, then fix the argument shape."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate arguments against the tool's schema before calling executeTool.","typeGuard":null,"tryCatchPattern":"try {\n  for (const tool of toolInputs) { ... await executeTool(tool, args); }\n} catch (e) {\n  if (e instanceof NodeOperationError && e.message.startsWith('Error executing tool:')) {\n    // inspect suffix, decide retry vs skip vs fail item\n  } else throw e;\n}","preventionTips":["Match tool arguments to the tool's input schema before execution.","Verify credentials and rate limits for API-backed tools.","Test tools in isolation with representative arguments."],"tags":["tool-executor","error-wrapping","catch-all","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}