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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(update_provider_when_message_created): Fix db transaction (#21503)
-LAN-3acaa5988532
diff --git a/api/events/event_handlers/update_provider_when_message_created.py b/api/events/event_handlers/update_provider_when_message_created.pyindex c64e842160b..d3943f2eda8 100644--- a/api/events/event_handlers/update_provider_when_message_created.py+++ b/api/events/event_handlers/update_provider_when_message_created.py@@ -5,6 +5,7 @@ from typing import Any, Optionalfrom pydantic import BaseModelfrom sqlalchemy import update+from sqlalchemy.orm import Sessionfrom configs import dify_configfrom core.app.entities.app_invoke_entities import AgentChatAppGenerateEntity, ChatAppGenerateEntity@@ -183,7 +184,7 @@ def _execute_provider_updates(updates_to_perform: list[_ProviderUpdateOperation]# Use SQLAlchemy's context manager for transaction management# This automatically handles commit/rollback- with db.session.begin():+ with Session(db.engine) as session:# Use a single transaction for all updatesfor update_operation in updates_to_perform:filters = update_operation.filters@@ -214,7 +215,7 @@ def _execute_provider_updates(updates_to_perform: list[_ProviderUpdateOperation]# Build and execute the update statementstmt = update(Provider).where(*where_conditions).values(**update_values)- result = db.session.execute(stmt)+ result = session.execute(stmt)rows_affected = result.rowcountlogger.debug(