mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-02 16:54:27 +08:00
fix: enhance file extension condition check for if-else node (#17060)
This commit is contained in:
parent
a1aa325ce3
commit
becd03a4aa
@ -375,11 +375,25 @@ def _process_sub_conditions(
|
||||
for condition in sub_conditions:
|
||||
key = FileAttribute(condition.key)
|
||||
values = [file_manager.get_attr(file=file, attr=key) for file in files]
|
||||
expected_value = condition.value
|
||||
if key == FileAttribute.EXTENSION:
|
||||
if not isinstance(expected_value, str):
|
||||
raise TypeError("Expected value must be a string when key is FileAttribute.EXTENSION")
|
||||
if expected_value and not expected_value.startswith("."):
|
||||
expected_value = "." + expected_value
|
||||
|
||||
normalized_values = []
|
||||
for value in values:
|
||||
if value and isinstance(value, str):
|
||||
if not value.startswith("."):
|
||||
value = "." + value
|
||||
normalized_values.append(value)
|
||||
values = normalized_values
|
||||
sub_group_results = [
|
||||
_evaluate_condition(
|
||||
value=value,
|
||||
operator=condition.comparison_operator,
|
||||
expected=condition.value,
|
||||
expected=expected_value,
|
||||
)
|
||||
for value in values
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user