Closed Angelxiaotao closed 3 days ago
The issue you're encountering seems to be related to how the code executor in Dify handles missing parameters in a conditional workflow. Currently, it appears that the code executor expects all defined parameters to be present, which leads to errors when a parameter is missing due to conditional logic.
To address this, you might consider implementing a check within your code to verify the existence of parameters before attempting to use them. This can be done by checking if the parameter exists in the VariablePool
before accessing it. If the parameter is not present, you can set a default value or skip the logic that requires it.
Unfortunately, there isn't specific documentation or configuration in Dify that allows the code executor to ignore missing parameters automatically. You may need to handle this within your workflow logic or code execution to ensure that missing parameters do not cause errors.
If this is a common requirement, you might want to suggest a feature enhancement to allow optional parameters in workflows, which could help prevent such issues in the future.
To continue talking to Dosu, mention @dosu.
This has been fixed in later version.
Self Checks
Dify version
0.11.0
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
In a conditional workflow setup, the code executor is configured to set the retrieval results of two knowledge bases as two parameters. Since our business logic requires selecting different knowledge bases based on conditions, when the if condition chooses only the A knowledge base (i.e., the code executor uses only the A parameter), the B parameter does not exist. This causes the code executor to throw an error. I have already tried implementing default values in Node.js to handle the missing parameters, but the issue persists with the same error
✔️ Expected Behavior
When the conditional logic selects only the A knowledge base, the B parameter should not be required. The code executor should execute normally, using only the available parameter.
❌ Actual Behavior
The code executor throws an error when parameter B is not present, causing the entire workflow to fail.