mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
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
This commit is contained in:
@ -421,7 +421,10 @@ class Executor:
|
|||||||
body_string += f"--{boundary}--\r\n"
|
body_string += f"--{boundary}--\r\n"
|
||||||
elif self.node_data.body:
|
elif self.node_data.body:
|
||||||
if self.content:
|
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":
|
elif self.data and self.node_data.body.type == "x-www-form-urlencoded":
|
||||||
body_string = urlencode(self.data)
|
body_string = urlencode(self.data)
|
||||||
elif self.data and self.node_data.body.type == "form-data":
|
elif self.data and self.node_data.body.type == "form-data":
|
||||||
|
|||||||
@ -171,6 +171,8 @@ class ListOperatorNode(Node):
|
|||||||
result = list(filter(filter_func, variable.value))
|
result = list(filter(filter_func, variable.value))
|
||||||
variable = variable.model_copy(update={"value": result})
|
variable = variable.model_copy(update={"value": result})
|
||||||
else:
|
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)
|
filter_func = _get_boolean_filter_func(condition=condition.comparison_operator, value=condition.value)
|
||||||
result = list(filter(filter_func, variable.value))
|
result = list(filter(filter_func, variable.value))
|
||||||
variable = variable.model_copy(update={"value": result})
|
variable = variable.model_copy(update={"value": result})
|
||||||
|
|||||||
Reference in New Issue
Block a user