mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 01:09:10 +08:00
fix(file_factory): validate upload_file_id format as UUID (#12084)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
50b7ec3c73
commit
754791efd3
@ -1,4 +1,5 @@
|
|||||||
import mimetypes
|
import mimetypes
|
||||||
|
import uuid
|
||||||
from collections.abc import Callable, Mapping, Sequence
|
from collections.abc import Callable, Mapping, Sequence
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
@ -119,6 +120,11 @@ def _build_from_local_file(
|
|||||||
upload_file_id = mapping.get("upload_file_id")
|
upload_file_id = mapping.get("upload_file_id")
|
||||||
if not upload_file_id:
|
if not upload_file_id:
|
||||||
raise ValueError("Invalid upload file id")
|
raise ValueError("Invalid upload file id")
|
||||||
|
# check if upload_file_id is a valid uuid
|
||||||
|
try:
|
||||||
|
uuid.UUID(upload_file_id)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError("Invalid upload file id format")
|
||||||
stmt = select(UploadFile).where(
|
stmt = select(UploadFile).where(
|
||||||
UploadFile.id == upload_file_id,
|
UploadFile.id == upload_file_id,
|
||||||
UploadFile.tenant_id == tenant_id,
|
UploadFile.tenant_id == tenant_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user