From 3fa11c9bbae5c9c8d6efcaab3769cd7a6c92e881 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Tue, 13 May 2025 16:28:59 +0800 Subject: [PATCH] fix: Prevent session expiration on commit Sets 'expire_on_commit' to False when creating a session to ensure that objects remain accessible after a commit. This change prevents potential issues with object expiration, improving reliability when accessing session data after committing transactions. Signed-off-by: -LAN- --- api/tasks/remove_app_and_related_data_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/tasks/remove_app_and_related_data_task.py b/api/tasks/remove_app_and_related_data_task.py index c6b67a4940..f61ff5fb30 100644 --- a/api/tasks/remove_app_and_related_data_task.py +++ b/api/tasks/remove_app_and_related_data_task.py @@ -192,7 +192,7 @@ def _delete_app_workflow_runs(tenant_id: str, app_id: str): def _delete_app_workflow_node_executions(tenant_id: str, app_id: str): # Get app's owner - with Session(db.engine) as session: + with Session(db.engine, expire_on_commit=False) as session: stmt = select(Account).where(Account.id == App.owner_id).where(App.id == app_id) user = session.scalar(stmt)