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: eagerly validate conversation before generator to prevent hanging (#37224)

functionkiller31a50a3b20a7
diff --git a/api/controllers/web/completion.py b/api/controllers/web/completion.py
index 2bb7db015ad..7871b411c4b 100644
--- a/api/controllers/web/completion.py
+++ b/api/controllers/web/completion.py
@@ -32,6 +32,7 @@ from libs.helper import uuid_value
from models.model import App, AppMode, EndUser
from services.app_generate_service import AppGenerateService
from services.app_task_service import AppTaskService
+from services.conversation_service import ConversationService
from services.errors.llm import InvokeRateLimitError
logger = logging.getLogger(__name__)
@@ -202,6 +203,12 @@ class ChatApi(WebApiResource):
args["auto_generate_name"] = False
try:
+ # Eagerly validate conversation to avoid hanging on invalid conversation_id
+ if payload.conversation_id:
+ ConversationService.get_conversation(
+ app_model=app_model, conversation_id=payload.conversation_id, user=end_user
+ )
+
response = AppGenerateService.generate(
app_model=app_model, user=end_user, args=args, invoke_from=InvokeFrom.WEB_APP, streaming=streaming
)