From 2ed6bb86c1339021e5f3850f6edbb7ee35a0621a Mon Sep 17 00:00:00 2001 From: crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Sun, 3 Nov 2024 12:53:49 +0800 Subject: [PATCH] Fix/10199 application error a client side exception has occurred see the browser console for more information (#10211) --- .../nodes/_base/hooks/use-one-step-run.ts | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts index 59ebb72b72..c500f0c8cf 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts @@ -105,32 +105,29 @@ const useOneStepRun = ({ const availableNodesIncludeParent = getBeforeNodesInSameBranchIncludeParent(id) const allOutputVars = toNodeOutputVars(availableNodes, isChatMode, undefined, undefined, conversationVariables) const getVar = (valueSelector: ValueSelector): Var | undefined => { - let res: Var | undefined const isSystem = valueSelector[0] === 'sys' - const targetVar = isSystem ? allOutputVars.find(item => !!item.isStartNode) : allOutputVars.find(v => v.nodeId === valueSelector[0]) + const targetVar = allOutputVars.find(item => isSystem ? !!item.isStartNode : item.nodeId === valueSelector[0]) if (!targetVar) return undefined + if (isSystem) return targetVar.vars.find(item => item.variable.split('.')[1] === valueSelector[1]) let curr: any = targetVar.vars - if (!curr) - return + for (let i = 1; i < valueSelector.length; i++) { + const key = valueSelector[i] + const isLast = i === valueSelector.length - 1 - valueSelector.slice(1).forEach((key, i) => { - const isLast = i === valueSelector.length - 2 - // conversation variable is start with 'conversation.' - curr = curr?.find((v: any) => v.variable.replace('conversation.', '') === key) - if (isLast) { - res = curr - } - else { - if (curr?.type === VarType.object || curr?.type === VarType.file) - curr = curr.children - } - }) + if (Array.isArray(curr)) + curr = curr.find((v: any) => v.variable.replace('conversation.', '') === key) - return res + if (isLast) + return curr + else if (curr?.type === VarType.object || curr?.type === VarType.file) + curr = curr.children + } + + return undefined } const checkValid = checkValidFns[data.type]