From 5cc0e986042acf88c9a8f7572e5529fdedb3be6c Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Tue, 21 Jan 2025 00:34:17 +0000 Subject: [PATCH] Bugfix/Allow prefix vars when executing custom function (#3902) allow prefix vars when executing custom function --- packages/server/src/services/nodes/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/server/src/services/nodes/index.ts b/packages/server/src/services/nodes/index.ts index 7dd8b2f93..25838de9c 100644 --- a/packages/server/src/services/nodes/index.ts +++ b/packages/server/src/services/nodes/index.ts @@ -123,6 +123,13 @@ const executeCustomFunction = async (requestBody: any) => { const functionInputVariables = Object.fromEntries( [...(body?.javascriptFunction ?? '').matchAll(/\$([a-zA-Z0-9_]+)/g)].map((g) => [g[1], undefined]) ) + if (functionInputVariables && Object.keys(functionInputVariables).length) { + for (const key in functionInputVariables) { + if (key.includes('vars')) { + delete functionInputVariables[key] + } + } + } const nodeData = { inputs: { functionInputVariables, ...body } } if (Object.prototype.hasOwnProperty.call(appServer.nodesPool.componentNodes, 'customFunction')) { try {