Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Conditional Workflow When Code Executor Handles Different Knowledge Base Parameters #11137

Closed
5 tasks done
Angelxiaotao opened this issue Nov 26, 2024 · 2 comments
Closed
5 tasks done
Labels
🐞 bug Something isn't working

Comments

@Angelxiaotao
Copy link

Angelxiaotao commented Nov 26, 2024

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

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

  1. Create a conditional workflow where the retrieval results of two knowledge bases are assigned as parameters A and B.
  2. Configure an if condition in the workflow to select only the A knowledge base result.
  3. During execution, the code executor attempts to access parameter B.
  4. The code executor throws an error because parameter B does not exist.

✔️ 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.
image
image

@dosubot dosubot bot added the 🐞 bug Something isn't working label Nov 26, 2024
Copy link

dosubot bot commented Nov 26, 2024

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.

@crazywoola
Copy link
Member

This has been fixed in later version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants