{"record":{"id":"0e04fab20a6520f4","repo":"langgenius/dify","slug":"workflow-not-found-0e04fa","errorCode":null,"errorMessage":"Workflow not found","messagePattern":"Workflow not found","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py","lineNumber":760,"sourceCode":"        update_data = req_data.model_dump(exclude_unset=True)\n\n        if not update_data:\n            return {\"message\": \"No valid fields to update\"}, 400\n\n        rag_pipeline_service = RagPipelineService(db.session())\n        workflow_ref = WorkflowRefService.create_pipeline_workflow_ref(pipeline, workflow_id)\n\n        # Create a session and manage the transaction\n        with sessionmaker(db.engine, expire_on_commit=False).begin() as session:\n            workflow = rag_pipeline_service.update_workflow(\n                session=session,\n                account_id=current_user.id,\n                data=update_data,\n                workflow_ref=workflow_ref,\n            )\n\n            if not workflow:\n                raise NotFound(\"Workflow not found\")\n\n            return dump_response(WorkflowResponse, workflow)\n\n    @console_ns.response(204, \"Workflow deleted successfully\")\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)\n    @get_rag_pipeline\n    def delete(self, pipeline: Pipeline, workflow_id: str):\n        \"\"\"\n        Delete a published workflow version that is not currently active on the pipeline.\n        \"\"\"\n        if pipeline.workflow_id == workflow_id:\n            abort(400, description=f\"Cannot delete workflow that is currently in use by pipeline '{pipeline.id}'\")\n\n        workflow_service = WorkflowService()","sourceCodeStart":742,"sourceCodeEnd":778,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py#L742-L778","documentation":"Raised as NotFound(\"Workflow not found\") (HTTP 404) in RagPipelineByIdApi.patch (PATCH /rag/pipelines/<pipeline_id>/workflows/<workflow_id>) when update_workflow returns a falsy value. After building a WorkflowRef from the path ids and applying update_data, the service cannot find a matching workflow row to update, so the controller returns 404.","triggerScenarios":"PATCHing a workflow_id that does not exist for the given pipeline, or one whose WorkflowRef cannot be resolved. The `if not workflow` branch then raises NotFound. (An empty update_data body is handled earlier as a 400, not here.)","commonSituations":"Editing a workflow that was just deleted by another user; workflow_id from a different pipeline; UI holding an old id after the list refreshed; sending an update after the workflow was archived/removed.","solutions":["Re-fetch the workflow list to obtain a valid, current workflow_id before PATCHing.","Verify pipeline_id and workflow_id belong together.","On the client, treat 404 as 'workflow no longer exists' and refresh the editor.","Ensure at least one updatable field is set so you do not hit the earlier 400 first."],"exampleFix":"// before\nPATCH /rag/pipelines/<id>/workflows/<wrong-id>  {\"name\": \"x\"}   // -> 404\n// after\nwf = await GET /rag/pipelines/<id>/workflows\nPATCH /rag/pipelines/<id>/workflows/<wf[0].id> {\"name\": \"x\"}","handlingStrategy":"try-catch","validationCode":"async function patchWorkflow(pipelineId, workflowId, data) {\n  if (!data || Object.keys(data).length === 0) throw new Error('no fields to update');\n  return fetch(`/rag/pipelines/${pipelineId}/workflows/${workflowId}`, {\n    method: 'PATCH', headers: {'Content-Type':'application/json'}, body: JSON.stringify(data)\n  });\n}","typeGuard":"function hasUpdatableFields(data) { return !!data && typeof data === 'object' && Object.keys(data).length > 0; }","tryCatchPattern":"try { await patchWorkflow(id, wfId, data); } catch (e) { if (e.status === 404) refreshWorkflows(); else if (e.status === 400) notifyNoFields(); else throw e; }","preventionTips":["Send at least one updatable field.","Refresh the workflow list after a 404.","Confirm pipeline_id and workflow_id are from the same context."],"tags":["rag-pipeline","workflow","not-found","http-404"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}