From 1c730a08047a5b3546ab27859a3636e8e4cf6904 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Sat, 21 Dec 2024 17:24:53 +0800 Subject: [PATCH] fix(file_factory): validate upload_file_id before querying UploadFile Signed-off-by: -LAN- --- api/factories/file_factory.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/factories/file_factory.py b/api/factories/file_factory.py index 01d95dcfb3d2fe..13034f5cf5688b 100644 --- a/api/factories/file_factory.py +++ b/api/factories/file_factory.py @@ -116,8 +116,11 @@ def _build_from_local_file( tenant_id: str, transfer_method: FileTransferMethod, ) -> File: + upload_file_id = mapping.get("upload_file_id") + if not upload_file_id: + raise ValueError("Invalid upload file id") stmt = select(UploadFile).where( - UploadFile.id == mapping.get("upload_file_id"), + UploadFile.id == upload_file_id, UploadFile.tenant_id == tenant_id, )