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: sqlalchemy.exc.InvalidRequestError: Can't operate on closed tran… (#34407)

wangxiaoleie41965061ceb
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 4251e7ebac3..70dfe47d7f8 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",