The Numeric Type in Structured Output Cannot Be Recognized by Downstream Components
Self Checks
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
1.3.0
Cloud or Self Hosted
Cloud
Steps to reproduce
When using the system, the upstream model defines a structured output of type number. However, the downstream branch node fails to recognize it, resulting in an error during execution: Invalid actual value type: string.
✔️ Expected Behavior
Expectation: The system should recognize the value as a Number and execute the branch logic based on numeric type.
❌ Actual Behavior
Invalid actual value type: string
Hello @pandy1715! I'm Dosu, your friendly bot here to help you tackle bugs, answer questions, and guide you on your journey to becoming a contributor. I'm here while you wait for a human maintainer. Let's get started!
To resolve the issue where the downstream components fail to recognize a numeric type in the structured output, resulting in an "Invalid actual value type: string" error, ensure that the output adheres to the JSON schema specified in the STRUCTURED_OUTPUT_PROMPT. Specifically, make sure that numeric values are output as numbers, not strings.
For example, if the JSON schema specifies a property with "type": "number", the output should be:
{"name": "John Doe", "age": 30}
Ensure that the numeric values are not enclosed in quotes, as this would make them strings [1].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
@dosu
I ran into a similar issue. One workaround is to use "string" as the structured output type instead of "Number". It is annoying, though.
I have a same issue with this on Dify 1.6.0. I create structured output as numeric, but next if-statement deal it as string.
https://cloud.dify.ai/ 1.7.2 I defined the variable as number in Structured Outputs, but it outputs as string.
"model_provider": "langgenius/siliconflow/siliconflow", "model_name": "deepseek-ai/DeepSeek-V3"
Hi, @pandy1715. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.
Issue Summary:
- You reported that numeric structured outputs in Dify 1.3.0 Cloud are incorrectly treated as strings by downstream branch nodes, causing execution errors.
- The suggested fix was to ensure numeric values are output as JSON numbers per the structured output schema.
- Other users confirmed the issue persists in versions 1.6.0 and 1.7.2.
- A common workaround has been to define the output type as string, which is inconvenient.
- The issue remains unresolved with no official fix implemented yet.
Next Steps:
- Please let me know if this issue is still relevant with the latest version of Dify by commenting here to keep the discussion open.
- Otherwise, this issue will be automatically closed in 15 days.
Thank you for your understanding and contribution!