Enhance file extension condition check in If-Else node #12304

Closed
opened 2026-02-21 19:06:49 -05:00 by yindo · 1 comment
Owner

Originally created by @lrhan321 on GitHub (Mar 28, 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

v1.1.3

Cloud or Self Hosted

Self Hosted (Source), Self Hosted (Docker)

Steps to reproduce

  1. Start node defines the file list variable
  2. Use sub-conditions in conditional branching to evaluate the file variable and determine the extension.
    Image

✔️ Expected Behavior

If the file list contains files with the extension pdf, EndNode 1 should be executed

Actual Behavior

Execution finally reached EndNode 2.

Image

Originally created by @lrhan321 on GitHub (Mar 28, 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 v1.1.3 ### Cloud or Self Hosted Self Hosted (Source), Self Hosted (Docker) ### Steps to reproduce 1. Start node defines the file list variable 2. Use sub-conditions in conditional branching to evaluate the file variable and determine the extension. ![Image](https://github.com/user-attachments/assets/c73b3c5a-0010-4314-9964-14f2017b831a) ### ✔️ Expected Behavior If the file list contains files with the extension `pdf`, `EndNode 1` should be executed ### ❌ Actual Behavior Execution finally reached `EndNode 2`. ![Image](https://github.com/user-attachments/assets/fe66b8a4-58d0-45c0-b1a8-1479dd6b4c8b)
yindo added the 🐞 bug label 2026-02-21 19:06:49 -05:00
yindo closed this issue 2026-02-21 19:06:49 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 28, 2025):

To enhance the file extension condition check in the If-Else node so that files with the extension pdf lead to the execution of EndNode 1, you can use the ComparisonOperator.is operator for the extension key. Here's how you can implement this:

const file = { key: 'extension', value: 'pdf' };
const operator = ComparisonOperator.is;

if (file.key === 'extension' && operator === ComparisonOperator.is && file.value === 'pdf') {
  // Execute EndNode 1
} else {
  // Execute EndNode 2
}

This code checks if the file's extension is pdf using the ComparisonOperator.is operator and directs the flow to EndNode 1 if the condition is met. Otherwise, it defaults to EndNode 2 [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 (Mar 28, 2025): <!-- Answer --> To enhance the file extension condition check in the If-Else node so that files with the extension `pdf` lead to the execution of `EndNode 1`, you can use the `ComparisonOperator.is` operator for the `extension` key. Here's how you can implement this: ```typescript const file = { key: 'extension', value: 'pdf' }; const operator = ComparisonOperator.is; if (file.key === 'extension' && operator === ComparisonOperator.is && file.value === 'pdf') { // Execute EndNode 1 } else { // Execute EndNode 2 } ``` This code checks if the file's extension is `pdf` using the `ComparisonOperator.is` operator and directs the flow to `EndNode 1` if the condition is met. Otherwise, it defaults to `EndNode 2` <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/nodes/if-else/utils.ts)</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/d12bf8b4-dbfe-49a3-81db-824a80675771?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/d12bf8b4-dbfe-49a3-81db-824a80675771?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/d12bf8b4-dbfe-49a3-81db-824a80675771?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/d12bf8b4-dbfe-49a3-81db-824a80675771?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d12bf8b4-dbfe-49a3-81db-824a80675771?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/d12bf8b4-dbfe-49a3-81db-824a80675771?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d12bf8b4-dbfe-49a3-81db-824a80675771?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12304