The Numeric Type in Structured Output Cannot Be Recognized by Downstream Components #13342

Closed
opened 2026-02-21 19:11:44 -05:00 by yindo · 6 comments
Owner

Originally created by @pandy1715 on GitHub (Apr 25, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • 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.

Image

✔️ Expected Behavior

Expectation: The system should recognize the value as a Number and execute the branch logic based on numeric type.
Image

Actual Behavior

Invalid actual value type: string

Image

Originally created by @pandy1715 on GitHub (Apr 25, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [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. ![Image](https://github.com/user-attachments/assets/2c6fd857-78bd-4a40-ae85-65eb3c6f8d89) ### ✔️ Expected Behavior Expectation: The system should recognize the value as a Number and execute the branch logic based on numeric type. ![Image](https://github.com/user-attachments/assets/b425aeb5-d0bc-4ae9-8346-3daf0c77e33a) ### ❌ Actual Behavior Invalid actual value type: string ![Image](https://github.com/user-attachments/assets/2bd934be-9b96-43fd-9930-6663b32dd7a9)
yindo added the 🐞 bugcloud labels 2026-02-21 19:11:44 -05:00
yindo closed this issue 2026-02-21 19:11:44 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 25, 2025):

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

@dosubot[bot] commented on GitHub (Apr 25, 2025): <!-- Greeting --> Hello @pandy1715! I'm [Dosu](https://dosu.dev), 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! <!-- Answer --> 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: ```json {"name": "John Doe", "age": 30} ``` Ensure that the numeric values are not enclosed in quotes, as this would make them strings <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/workflow/utils/structured_output/prompt.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/92ac4ee7-6aa0-4408-89e9-9fcf7c1cd172?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/92ac4ee7-6aa0-4408-89e9-9fcf7c1cd172?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/92ac4ee7-6aa0-4408-89e9-9fcf7c1cd172?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/92ac4ee7-6aa0-4408-89e9-9fcf7c1cd172?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/92ac4ee7-6aa0-4408-89e9-9fcf7c1cd172?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/92ac4ee7-6aa0-4408-89e9-9fcf7c1cd172?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/92ac4ee7-6aa0-4408-89e9-9fcf7c1cd172?feedback_type=other)</sup>
Author
Owner

@pandy1715 commented on GitHub (Apr 25, 2025):

Image
@dosu

@pandy1715 commented on GitHub (Apr 25, 2025): ![Image](https://github.com/user-attachments/assets/2dd82eed-52f6-4e2c-ac12-7e418de42560) @dosu
Author
Owner

@Lw-Cui commented on GitHub (Jul 16, 2025):

I ran into a similar issue. One workaround is to use "string" as the structured output type instead of "Number". It is annoying, though.

@Lw-Cui commented on GitHub (Jul 16, 2025): I ran into a similar issue. One workaround is to use "string" as the structured output type instead of "Number". It is annoying, though.
Author
Owner

@t-ikeda-mm commented on GitHub (Aug 1, 2025):

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.

Image
@t-ikeda-mm commented on GitHub (Aug 1, 2025): 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. <img width="1067" height="297" alt="Image" src="https://github.com/user-attachments/assets/b0b396a5-a5eb-46ea-bd6d-19daa435458a" />
Author
Owner

@johnduan888 commented on GitHub (Aug 16, 2025):

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"

Image Image
@johnduan888 commented on GitHub (Aug 16, 2025): 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" <img width="446" height="422" alt="Image" src="https://github.com/user-attachments/assets/c4a72fad-cf80-4d64-9497-c9409f8265fc" /> <img width="467" height="990" alt="Image" src="https://github.com/user-attachments/assets/fe4241ae-2877-45b6-beed-b2170f1057ed" />
Author
Owner

@dosubot[bot] commented on GitHub (Sep 16, 2025):

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!

@dosubot[bot] commented on GitHub (Sep 16, 2025): Hi, @pandy1715. I'm [Dosu](https://dosu.dev), 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13342