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 incorrect assert type in the AgentNode class (#22964)

Yongtao Huang31985d94fa41
diff --git a/api/core/workflow/nodes/agent/agent_node.py b/api/core/workflow/nodes/agent/agent_node.py
index c83303034e2..2b6382a8a66 100644
--- a/api/core/workflow/nodes/agent/agent_node.py
+++ b/api/core/workflow/nodes/agent/agent_node.py
@@ -50,6 +50,7 @@ from .exc import (
AgentInputTypeError,
AgentInvocationError,
AgentMessageTransformError,
+ AgentNodeError,
AgentVariableNotFoundError,
AgentVariableTypeError,
ToolFileNotFoundError,
@@ -593,7 +594,14 @@ class AgentNode(BaseNode):
variables[variable_name] = variable_value
elif message.type == ToolInvokeMessage.MessageType.FILE:
assert message.meta is not None
- assert isinstance(message.meta, File)
+ assert isinstance(message.meta, dict)
+ # Validate that meta contains a 'file' key
+ if "file" not in message.meta:
+ raise AgentNodeError("File message is missing 'file' key in meta")
+
+ # Validate that the file is an instance of File
+ if not isinstance(message.meta["file"], File):
+ raise AgentNodeError(f"Expected File object but got {type(message.meta['file']).__name__}")
files.append(message.meta["file"])
elif message.type == ToolInvokeMessage.MessageType.LOG:
assert isinstance(message.message, ToolInvokeMessage.LogMessage)