From e41965061ceb78bb574d1eac60fa18fb7b3e0e98 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 | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 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 4251e7ebac..70dfe47d7f 100644 --- a/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py +++ b/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py @@ -593,17 +593,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 sessionmaker(db.engine).begin() 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) + 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",