From 5dcc571f720e2e7f4ffd82d03e1c7a8b728175f1 Mon Sep 17 00:00:00 2001 From: Charlie Kolb Date: Tue, 19 Nov 2024 11:08:53 +0100 Subject: [PATCH] cleanup two --- .../nodes/tools/ToolWorkflow/ToolWorkflow.node.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/ToolWorkflow.node.ts b/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/ToolWorkflow.node.ts index 2110976bb2a4a..d85ff722712b2 100644 --- a/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/ToolWorkflow.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/tools/ToolWorkflow/ToolWorkflow.node.ts @@ -519,15 +519,10 @@ export class ToolWorkflow implements INodeType { if (executionError) { void this.addOutputData(NodeConnectionType.AiTool, index, executionError, metadata); } else { - const parsedResponse = jsonParse(response); // Output always needs to be an object // so we try to parse the response as JSON and if it fails we just return the string wrapped in an object - void this.addOutputData( - NodeConnectionType.AiTool, - index, - [[{ json: typeof parsedResponse === 'object' ? parsedResponse : { response } }]], - metadata, - ); + const json = jsonParse(response, { fallbackValue: { response } }); + void this.addOutputData(NodeConnectionType.AiTool, index, [[{ json }]], metadata); } return response; };