From 2e6446454defbd3e5a47b66e6fd46d4f1b9fbd0f Mon Sep 17 00:00:00 2001 From: oleg Date: Thu, 24 Oct 2024 22:50:18 +0200 Subject: [PATCH] fix(core): Fix resolving of $fromAI expression via `evaluateExpression` (#11397) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ --- packages/core/src/NodeExecuteFunctions.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 232442be98..529d6fc94b 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -2856,6 +2856,8 @@ async function getInputConnectionData( connectedNode.typeVersion, ); + // TODO: create a new context object here based on the type of `connectedNode`, and avoid using `Object.assign` on context objects + // https://linear.app/n8n/issue/CAT-269 const context = Object.assign({}, this); context.getNodeParameter = ( @@ -3758,14 +3760,16 @@ export function getExecuteFunctions( continueOnFail: () => { return continueOnFail(node); }, - evaluateExpression: (expression: string, itemIndex: number) => { + evaluateExpression(expression: string, itemIndex: number) { return workflow.expression.resolveSimpleParameterValue( `=${expression}`, {}, runExecutionData, runIndex, itemIndex, - node.name, + // TODO: revert this back to `node.name` when we stop using `IExecuteFunctions` as the context object in AI nodes. + // https://linear.app/n8n/issue/CAT-269 + this.getNode().name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData),