Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix: Prevent binary content from being stored in process_data for HTTP nodes (#27532)

AuditAIH693877e5e48d
diff --git a/api/core/workflow/nodes/http_request/executor.py b/api/core/workflow/nodes/http_request/executor.py
index 7b5b9c9e866..f0c84872fbf 100644
--- a/api/core/workflow/nodes/http_request/executor.py
+++ b/api/core/workflow/nodes/http_request/executor.py
@@ -412,16 +412,20 @@ class Executor:
body_string += f"--{boundary}\r\n"
body_string += f'Content-Disposition: form-data; name="{key}"\r\n\r\n'
# decode content safely
- try:
- body_string += content.decode("utf-8")
- except UnicodeDecodeError:
- body_string += content.decode("utf-8", errors="replace")
- body_string += "\r\n"
+ # Do not decode binary content; use a placeholder with file metadata instead.
+ # Includes filename, size, and MIME type for better logging context.
+ body_string += (
+ f"<file_content_binary: '{file_entry[1][0] or 'unknown'}', "
+ f"type='{file_entry[1][2] if len(file_entry[1]) > 2 else 'unknown'}', "
+ f"size={len(content)} bytes>\r\n"
+ )
body_string += f"--{boundary}--\r\n"
elif self.node_data.body:
if self.content:
+ # If content is bytes, do not decode it; show a placeholder with size.
+ # Provides content size information for binary data without exposing the raw bytes.
if isinstance(self.content, bytes):
- body_string = self.content.decode("utf-8", errors="replace")
+ body_string = f"<binary_content: size={len(self.content)} bytes>"
else:
body_string = self.content
elif self.data and self.node_data.body.type == "x-www-form-urlencoded":