Open JokerQyou opened 3 hours ago
To resolve the validation error you're encountering in the Dify workflow tool, ensure that the number is passed as a type that the tool node expects. According to the Dify code, the ToolInput
class expects the value
to be of type str
, int
, float
, or bool
when the type
is "constant"
.
Here's how you can ensure the correct type is passed:
type
is "constant"
, make sure the value is explicitly cast to one of the accepted types (str
, int
, float
, or bool
). For example, if you are passing a number, ensure it is not wrapped in a list or any other structure.Example:
tool_input = ToolNodeData.ToolInput(value=42, type="constant")
type
is "mixed"
, ensure the value is a string.Example:
tool_input = ToolNodeData.ToolInput(value="42", type="mixed")
type
is "variable"
, ensure the value is a list of strings.Example:
tool_input = ToolNodeData.ToolInput(value=["42"], type="variable")
By ensuring the value matches the expected type for the specified type
, you should be able to resolve the validation error [1].
To continue talking to Dosu, mention @dosu.
Of course I passed it as number. You can import the workflows I uploaded (in the first comment) to check it yourself. Also I'm on a docker installation so there is no easy way to tweak dify source code, so can't verify what you suggested.
Self Checks
Dify version
0.10.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
Here is these two workflows (file extension changed to
.txt
due to GitHub issue restriction):test-tool
is the tool workflow,test
is the workflow to reproduce this bug.test.yml.txt test-tool.yml.txt
Screenshot of variable passing to tool workflow:
Screenshot of type error during workflow execution:
The error text is:
I checked multiple times that this is not due to my app code bug like mismatched variable type configured on the UI or something like that. This seems to be a dify bug.
test.yml.txt test-tool.yml.txt
✔️ Expected Behavior
The
test
workflow runs fine.❌ Actual Behavior
Errors out with
1 validation error for ToolNodeData tool_parameters.i.type Value error, value must be a string, int, float, or bool [type=value_error, input_value='constant', input_type=str]
.