Browse Source

Fix/10199 application error a client side exception has occurred see the browser console for more information (#10211)

crazywoola 8 months ago
parent
commit
2ed6bb86c1
1 changed files with 14 additions and 17 deletions
  1. 14 17
      web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts

+ 14 - 17
web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts

@@ -105,32 +105,29 @@ const useOneStepRun = <T>({
   const availableNodesIncludeParent = getBeforeNodesInSameBranchIncludeParent(id)
   const availableNodesIncludeParent = getBeforeNodesInSameBranchIncludeParent(id)
   const allOutputVars = toNodeOutputVars(availableNodes, isChatMode, undefined, undefined, conversationVariables)
   const allOutputVars = toNodeOutputVars(availableNodes, isChatMode, undefined, undefined, conversationVariables)
   const getVar = (valueSelector: ValueSelector): Var | undefined => {
   const getVar = (valueSelector: ValueSelector): Var | undefined => {
-    let res: Var | undefined
     const isSystem = valueSelector[0] === 'sys'
     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)
     if (!targetVar)
       return undefined
       return undefined
+
     if (isSystem)
     if (isSystem)
       return targetVar.vars.find(item => item.variable.split('.')[1] === valueSelector[1])
       return targetVar.vars.find(item => item.variable.split('.')[1] === valueSelector[1])
 
 
     let curr: any = targetVar.vars
     let curr: any = targetVar.vars
-    if (!curr)
+    for (let i = 1; i < valueSelector.length; i++) {
-      return
+      const key = valueSelector[i]
+      const isLast = i === valueSelector.length - 1
 
 
-    valueSelector.slice(1).forEach((key, i) => {
+      if (Array.isArray(curr))
-      const isLast = i === valueSelector.length - 2
+        curr = curr.find((v: any) => v.variable.replace('conversation.', '') === key)
-      // conversation variable is start with 'conversation.'
+
-      curr = curr?.find((v: any) => v.variable.replace('conversation.', '') === key)
+      if (isLast)
-      if (isLast) {
+        return curr
-        res = curr
+      else if (curr?.type === VarType.object || curr?.type === VarType.file)
-      }
+        curr = curr.children
-      else {
+    }
-        if (curr?.type === VarType.object || curr?.type === VarType.file)
-          curr = curr.children
-      }
-    })
 
 
-    return res
+    return undefined
   }
   }
 
 
   const checkValid = checkValidFns[data.type]
   const checkValid = checkValidFns[data.type]