From 5ab3526845988ff6ef3b5040df17d9dda4cd0508 Mon Sep 17 00:00:00 2001 From: wangxiaolei Date: Wed, 1 Apr 2026 21:15:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20sqlalchemy.exc.InvalidRequestError:=20Ca?= =?UTF-8?q?n't=20operate=20on=20closed=20tran=E2=80=A6=20(#34407)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rag_pipeline/rag_pipeline_workflow.py | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py index 3912cc73cac..93e93609e8a 100644 --- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py +++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py @@ -607,19 +607,15 @@ class PublishedRagPipelineApi(Resource): # The role of the current user in the ta table must be admin, owner, or editor current_user, _ = current_account_with_tenant() rag_pipeline_service = RagPipelineService() - with Session(db.engine) as session: - pipeline = session.merge(pipeline) - workflow = rag_pipeline_service.publish_workflow( - session=session, - pipeline=pipeline, - account=current_user, - ) - pipeline.is_published = True - pipeline.workflow_id = workflow.id - session.add(pipeline) - workflow_created_at = TimestampField().format(workflow.created_at) - - session.commit() + workflow = rag_pipeline_service.publish_workflow( + session=db.session, # type: ignore[reportArgumentType,arg-type] + pipeline=pipeline, + account=current_user, + ) + pipeline.is_published = True + pipeline.workflow_id = workflow.id + db.session.commit() + workflow_created_at = TimestampField().format(workflow.created_at) return { "result": "success",