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 7a1fbdb7f8..c460ee0d5e 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts +++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts @@ -402,29 +402,32 @@ const getIterationItemType = ({ beforeNodesOutputVars: NodeOutPutVar[] }): VarType => { const outputVarNodeId = valueSelector[0] - const targetVar = beforeNodesOutputVars.find(v => v.nodeId === outputVarNodeId) + const isSystem = isSystemVar(valueSelector) + + const targetVar = isSystem ? beforeNodesOutputVars.find(v => v.isStartNode) : beforeNodesOutputVars.find(v => v.nodeId === outputVarNodeId) if (!targetVar) return VarType.string let arrayType: VarType = VarType.string - const isSystem = isSystemVar(valueSelector) let curr: any = targetVar.vars + if (isSystem) { + arrayType = curr.find((v: any) => v.variable === (valueSelector).join('.'))?.type + } + else { + (valueSelector).slice(1).forEach((key, 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 + } + }) + } - if (isSystem) - return curr.find((v: any) => v.variable === (valueSelector).join('.'))?.type; - - (valueSelector).slice(1).forEach((key, 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 - } - }) switch (arrayType as VarType) { case VarType.arrayString: return VarType.string @@ -435,7 +438,7 @@ const getIterationItemType = ({ case VarType.array: return VarType.any case VarType.arrayFile: - return VarType.object + return VarType.file default: return VarType.string }