mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 17:58:59 +08:00
fix: add UUID validation for tool file ID extraction (#12011)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
75bce2822e
commit
d0dd8b7955
@ -1,5 +1,6 @@
|
|||||||
from collections.abc import Mapping, Sequence
|
from collections.abc import Mapping, Sequence
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
@ -231,6 +232,10 @@ class ToolNode(BaseNode[ToolNodeData]):
|
|||||||
url = str(response.message)
|
url = str(response.message)
|
||||||
transfer_method = FileTransferMethod.TOOL_FILE
|
transfer_method = FileTransferMethod.TOOL_FILE
|
||||||
tool_file_id = url.split("/")[-1].split(".")[0]
|
tool_file_id = url.split("/")[-1].split(".")[0]
|
||||||
|
try:
|
||||||
|
UUID(tool_file_id)
|
||||||
|
except ValueError:
|
||||||
|
raise ToolFileError(f"cannot extract tool file id from url {url}")
|
||||||
with Session(db.engine) as session:
|
with Session(db.engine) as session:
|
||||||
stmt = select(ToolFile).where(ToolFile.id == tool_file_id)
|
stmt = select(ToolFile).where(ToolFile.id == tool_file_id)
|
||||||
tool_file = session.scalar(stmt)
|
tool_file = session.scalar(stmt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user