From d9aa0ec046adaafc8ff0ce80b1111f5d917f62cd Mon Sep 17 00:00:00 2001 From: -LAN- Date: Fri, 5 Sep 2025 21:17:18 +0800 Subject: [PATCH] fix: resolve mypy type errors in http_request and list_operator nodes - Fix str | bytes union type handling in http_request executor - Add type guard for boolean filter value in list_operator node --- api/core/workflow/nodes/http_request/executor.py | 5 ++++- api/core/workflow/nodes/list_operator/node.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api/core/workflow/nodes/http_request/executor.py b/api/core/workflow/nodes/http_request/executor.py index a0319cfe5f..c47ffb5ab0 100644 --- a/api/core/workflow/nodes/http_request/executor.py +++ b/api/core/workflow/nodes/http_request/executor.py @@ -421,7 +421,10 @@ class Executor: body_string += f"--{boundary}--\r\n" elif self.node_data.body: if self.content: - body_string = self.content.decode("utf-8", errors="replace") + if isinstance(self.content, bytes): + body_string = self.content.decode("utf-8", errors="replace") + else: + body_string = self.content elif self.data and self.node_data.body.type == "x-www-form-urlencoded": body_string = urlencode(self.data) elif self.data and self.node_data.body.type == "form-data": diff --git a/api/core/workflow/nodes/list_operator/node.py b/api/core/workflow/nodes/list_operator/node.py index 96220b635b..db8de2fa05 100644 --- a/api/core/workflow/nodes/list_operator/node.py +++ b/api/core/workflow/nodes/list_operator/node.py @@ -171,6 +171,8 @@ class ListOperatorNode(Node): result = list(filter(filter_func, variable.value)) variable = variable.model_copy(update={"value": result}) else: + if not isinstance(condition.value, bool): + raise ValueError(f"Boolean filter expects a boolean value, got {type(condition.value)}") filter_func = _get_boolean_filter_func(condition=condition.comparison_operator, value=condition.value) result = list(filter(filter_func, variable.value)) variable = variable.model_copy(update={"value": result})