From 03ac2d0f17696fe5e2b0f218a3e82920b40f4e6a Mon Sep 17 00:00:00 2001 From: crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Mon, 28 Apr 2025 11:09:54 +0800 Subject: [PATCH] fix: i.find is not a function (#18945) --- .../nodes/_base/components/variable/utils.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts index 99faf77276..efbd663630 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -596,17 +596,16 @@ const getIterationItemType = ({ arrayType = curr.find((v: any) => v.variable === (valueSelector).join('.'))?.type } else { - (valueSelector).slice(1).forEach((key, i) => { + for (let i = 1; i < valueSelector.length - 1; i++) { + const key = valueSelector[i] const isLast = i === valueSelector.length - 2 - curr = curr?.find((v: any) => v.variable === key) - if (isLast) { - arrayType = curr?.type - } - else { - if (curr?.type === VarType.object || curr?.type === VarType.file) - curr = curr.children - } - }) + curr = Array.isArray(curr) ? curr.find(v => v.variable === key) : [] + + if (isLast) + arrayType = curr?.type + else if (curr?.type === VarType.object || curr?.type === VarType.file) + curr = curr.children || [] + } } switch (arrayType as VarType) { @@ -631,7 +630,7 @@ const getLoopItemType = ({ }: { valueSelector: ValueSelector beforeNodesOutputVars: NodeOutPutVar[] - // eslint-disable-next-line sonarjs/no-identical-functions + }): VarType => { const outputVarNodeId = valueSelector[0] const isSystem = isSystemVar(valueSelector)