Clean up legacy conditions data in if-else nodes to prevent misjudgments (#28148)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,7 @@ import type { RAGPipelineVariable } from '@/models/pipeline'
|
||||
import type { WebhookTriggerNodeType } from '@/app/components/workflow/nodes/trigger-webhook/types'
|
||||
import type { PluginTriggerNodeType } from '@/app/components/workflow/nodes/trigger-plugin/types'
|
||||
import PluginTriggerNodeDefault from '@/app/components/workflow/nodes/trigger-plugin/default'
|
||||
|
||||
import type { CaseItem, Condition } from '@/app/components/workflow/nodes/if-else/types'
|
||||
import {
|
||||
AGENT_OUTPUT_STRUCT,
|
||||
FILE_STRUCT,
|
||||
@@ -1305,10 +1305,7 @@ export const getNodeUsedVars = (node: Node): ValueSelector[] => {
|
||||
break
|
||||
}
|
||||
case BlockEnum.IfElse: {
|
||||
res
|
||||
= (data as IfElseNodeType).conditions?.map((c) => {
|
||||
return c.variable_selector || []
|
||||
}) || []
|
||||
res = []
|
||||
res.push(
|
||||
...((data as IfElseNodeType).cases || [])
|
||||
.flatMap(c => c.conditions || [])
|
||||
@@ -1480,9 +1477,22 @@ export const getNodeUsedVarPassToServerKey = (
|
||||
break
|
||||
}
|
||||
case BlockEnum.IfElse: {
|
||||
const targetVar = (data as IfElseNodeType).conditions?.find(
|
||||
c => c.variable_selector?.join('.') === valueSelector.join('.'),
|
||||
)
|
||||
const findConditionInCases = (cases: CaseItem[]): Condition | undefined => {
|
||||
for (const caseItem of cases) {
|
||||
for (const condition of caseItem.conditions || []) {
|
||||
if (condition.variable_selector?.join('.') === valueSelector.join('.'))
|
||||
return condition
|
||||
|
||||
if (condition.sub_variable_condition) {
|
||||
const found = findConditionInCases([condition.sub_variable_condition])
|
||||
if (found)
|
||||
return found
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
const targetVar = findConditionInCases((data as IfElseNodeType).cases || [])
|
||||
if (targetVar) res = `#${valueSelector.join('.')}#`
|
||||
break
|
||||
}
|
||||
@@ -1634,13 +1644,6 @@ export const updateNodeVars = (
|
||||
}
|
||||
case BlockEnum.IfElse: {
|
||||
const payload = data as IfElseNodeType
|
||||
if (payload.conditions) {
|
||||
payload.conditions = payload.conditions.map((c) => {
|
||||
if (c.variable_selector?.join('.') === oldVarSelector.join('.'))
|
||||
c.variable_selector = newVarSelector
|
||||
return c
|
||||
})
|
||||
}
|
||||
if (payload.cases) {
|
||||
payload.cases = payload.cases.map((caseItem) => {
|
||||
if (caseItem.conditions) {
|
||||
|
||||
Reference in New Issue
Block a user