Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: s.filter is not a function (#19250)

crazywoola9231c197a52d
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 efbd663630c..d56c636f550 100644
--- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts
+++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts
@@ -134,18 +134,33 @@ const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: Val
const { children } = obj
const isStructuredOutput = !!(children as StructuredOutput)?.schema?.properties
+ let childrenResult: Var[] | StructuredOutput | undefined
+
+ if (isStructuredOutput) {
+ childrenResult = findExceptVarInStructuredOutput(children, filterVar)
+ }
+ else if (Array.isArray(children)) {
+ childrenResult = children.filter((item: Var) => {
+ const { children: itemChildren } = item
+ const currSelector = [...value_selector, item.variable]
+
+ if (!itemChildren)
+ return filterVar(item, currSelector)
+
+ const filteredObj = findExceptVarInObject(item, filterVar, currSelector, false) // File doesn't contain file children
+ return filteredObj.children && (filteredObj.children as Var[])?.length > 0
+ })
+ }
+ else {
+ childrenResult = []
+ }
+
const res: Var = {
variable: obj.variable,
type: isFile ? VarType.file : VarType.object,
- children: isStructuredOutput ? findExceptVarInStructuredOutput(children, filterVar) : children.filter((item: Var) => {
- const { children } = item
- const currSelector = [...value_selector, item.variable]
- if (!children)
- return filterVar(item, currSelector)
- const obj = findExceptVarInObject(item, filterVar, currSelector, false) // File doesn't contains file children
- return obj.children && (obj.children as Var[])?.length > 0
- }),
+ children: childrenResult,
}
+
return res
}