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: tool constant params change cause page crashed (#11682)

Joel607a22ad1221
diff --git a/web/app/components/workflow/nodes/tool/components/input-var-list.tsx b/web/app/components/workflow/nodes/tool/components/input-var-list.tsx
index 5d29b767ad6..db1a32e3192 100644
--- a/web/app/components/workflow/nodes/tool/components/input-var-list.tsx
+++ b/web/app/components/workflow/nodes/tool/components/input-var-list.tsx
@@ -61,20 +61,12 @@ const InputVarList: FC<Props> = ({
const newValue = produce(value, (draft: ToolVarInputs) => {
const target = draft[variable]
if (target) {
- if (!isSupportConstantValue || varKindType === VarKindType.variable) {
- if (isSupportConstantValue)
- target.type = VarKindType.variable
-
- target.value = varValue as ValueSelector
- }
- else {
- target.type = VarKindType.constant
- target.value = varValue as string
- }
+ target.type = varKindType
+ target.value = varValue
}
else {
draft[variable] = {
- type: VarKindType.variable,
+ type: varKindType,
value: varValue,
}
}
@@ -173,7 +165,7 @@ const InputVarList: FC<Props> = ({
value={varInput?.type === VarKindType.constant ? (varInput?.value || '') : (varInput?.value || [])}
onChange={handleNotMixedTypeChange(variable)}
onOpen={handleOpen(index)}
- defaultVarKindType={isNumber ? VarKindType.constant : VarKindType.variable}
+ defaultVarKindType={varInput?.type || (isNumber ? VarKindType.constant : VarKindType.variable)}
isSupportConstantValue={isSupportConstantValue}
filterVar={isNumber ? filterVar : undefined}
availableVars={isSelect ? availableVars : undefined}
diff --git a/web/app/components/workflow/nodes/tool/use-config.ts b/web/app/components/workflow/nodes/tool/use-config.ts
index df8ad47985b..94046ba4fa3 100644
--- a/web/app/components/workflow/nodes/tool/use-config.ts
+++ b/web/app/components/workflow/nodes/tool/use-config.ts
@@ -132,7 +132,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
draft.tool_parameters = {}
})
setInputs(inputsWithDefaultValue)
- // eslint-disable-next-line react-hooks/exhaustive-deps
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [currTool])
// setting when call
@@ -214,8 +214,13 @@ const useConfig = (id: string, payload: ToolNodeType) => {
.map(k => inputs.tool_parameters[k])
const varInputs = getInputVars(hadVarParams.map((p) => {
- if (p.type === VarType.variable)
+ if (p.type === VarType.variable) {
+ // handle the old wrong value not crash the page
+ if (!(p.value as any).join)
+ return `{{#${p.value}#}}`
+
return `{{#${(p.value as ValueSelector).join('.')}#}}`
+ }
return p.value as string
}))