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: chat api in explore page reject blank conversation id (#29500)

-LAN-281e9d4f51b6
diff --git a/api/controllers/console/explore/completion.py b/api/controllers/console/explore/completion.py
index 78e9a87a3db..5901eca915f 100644
--- a/api/controllers/console/explore/completion.py
+++ b/api/controllers/console/explore/completion.py
@@ -2,7 +2,7 @@ import logging
from typing import Any, Literal
from uuid import UUID
-from pydantic import BaseModel, Field
+from pydantic import BaseModel, Field, field_validator
from werkzeug.exceptions import InternalServerError, NotFound
import services
@@ -52,10 +52,24 @@ class ChatMessagePayload(BaseModel):
inputs: dict[str, Any]
query: str
files: list[dict[str, Any]] | None = None
- conversation_id: UUID | None = None
- parent_message_id: UUID | None = None
+ conversation_id: str | None = None
+ parent_message_id: str | None = None
retriever_from: str = Field(default="explore_app")
+ @field_validator("conversation_id", "parent_message_id", mode="before")
+ @classmethod
+ def normalize_uuid(cls, value: str | UUID | None) -> str | None:
+ """
+ Accept blank IDs and validate UUID format when provided.
+ """
+ if not value:
+ return None
+
+ try:
+ return helper.uuid_value(value)
+ except ValueError as exc:
+ raise ValueError("must be a valid UUID") from exc
+
register_schema_models(console_ns, CompletionMessagePayload, ChatMessagePayload)