When the value of the variable is 0, the variable is treated as null, resulting in an error in the Python calculation.
Self Checks
- [X] This is only for bug report, if you would like to ask a quesion, 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] Pleas do not modify this template :) and fill in all the required fields.
Dify version
0.6.5
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
I need some variables to perform some calculations. If the value of the variable is 0, it will be null when I call it in the subsequent nodes, which will cause an error in the Python code calculation. Please refer to the picture.
✔️ Expected Behavior
0
❌ Actual Behavior
null
The behavior you're encountering, where a variable with a value of 0 is treated as null in your Python code, could be due to how your code or the Dify framework you're using interprets numerical values, especially in conditions or functions designed to check for null or None values. It's crucial to ensure that your code differentiates between None (null in Python) and 0, as they have different meanings. Specifically, check the logic around any _assert_null or _assert_not_null methods or similar conditions that might mistakenly treat 0 as None.
To address this issue, review the initialization and handling of variables that can have a 0 value to ensure they are not inadvertently treated as None when passed through your workflow or calculations. This includes checking any custom logic that evaluates these variables before they are used in calculations or passed to functions that expect a non-null value.
If your setup is self-hosted using Docker, consider also reviewing your Docker configuration and how it interacts with Dify, although without more specific details on your Docker setup and the steps leading to the issue, it's challenging to provide a targeted solution. Ensure your Docker setup aligns with the recommended configurations as outlined in Dify's documentation.
For more detailed guidance, reviewing the Dify repository and the Dify Docker Compose Deployment documentation might provide additional insights into handling such issues.
Details
Sources
- api/core/workflow/nodes/if_else/if_else_node.py
- web/app/components/workflow/constants.ts
- en/features/workflow/node/variable-assigner.md
- en/getting-started/install-self-hosted/docker-compose.md
- docker/docker-compose.yaml
- docker/docker-compose.middleware.yaml
About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.