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: fix db session already begin (#29160)

wangxiaoleicc6c59b27ac0
diff --git a/api/core/app/apps/message_based_app_generator.py b/api/core/app/apps/message_based_app_generator.py
index 246ec7d7860..57617d8863f 100644
--- a/api/core/app/apps/message_based_app_generator.py
+++ b/api/core/app/apps/message_based_app_generator.py
@@ -156,7 +156,7 @@ class MessageBasedAppGenerator(BaseAppGenerator):
query = application_generate_entity.query or "New conversation"
conversation_name = (query[:20] + "…") if len(query) > 20 else query
- with db.session.begin():
+ try:
if not conversation:
conversation = Conversation(
app_id=app_config.app_id,
@@ -232,7 +232,10 @@ class MessageBasedAppGenerator(BaseAppGenerator):
db.session.add_all(message_files)
db.session.commit()
- return conversation, message
+ return conversation, message
+ except Exception:
+ db.session.rollback()
+ raise
def _get_conversation_introduction(self, application_generate_entity: AppGenerateEntity) -> str:
"""