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: allow optional config parameter and conditionally include message file ID (#26960)

Guangdong Liu598dd1f816f4
diff --git a/api/factories/file_factory.py b/api/factories/file_factory.py
index 735fff53d16..231e8054606 100644
--- a/api/factories/file_factory.py
+++ b/api/factories/file_factory.py
@@ -21,7 +21,7 @@ def build_from_message_files(
*,
message_files: Sequence["MessageFile"],
tenant_id: str,
- config: FileUploadConfig,
+ config: FileUploadConfig | None = None,
) -> Sequence[File]:
results = [
build_from_message_file(message_file=file, tenant_id=tenant_id, config=config)
@@ -35,15 +35,18 @@ def build_from_message_file(
*,
message_file: "MessageFile",
tenant_id: str,
- config: FileUploadConfig,
+ config: FileUploadConfig | None,
):
mapping = {
"transfer_method": message_file.transfer_method,
"url": message_file.url,
- "id": message_file.id,
"type": message_file.type,
}
+ # Only include id if it exists (message_file has been committed to DB)
+ if message_file.id:
+ mapping["id"] = message_file.id
+
# Set the correct ID field based on transfer method
if message_file.transfer_method == FileTransferMethod.TOOL_FILE:
mapping["tool_file_id"] = message_file.upload_file_id