{"record":{"id":"e91db4d9ae3fe180","repo":"langgenius/dify","slug":"workflow-node-execution-not-found","errorCode":null,"errorMessage":"Workflow node execution not found","messagePattern":"Workflow node execution not found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py","lineNumber":500,"sourceCode":"    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)\n    @account_initialization_required\n    @with_current_user\n    @get_rag_pipeline\n    @model_validate(NodeRunRequiredPayload)\n    def post(self, req_data: NodeRunRequiredPayload, current_user: Account, pipeline: Pipeline, node_id: str):\n        \"\"\"\n        Run draft workflow node\n        \"\"\"\n        inputs = req_data.inputs\n\n        rag_pipeline_service = RagPipelineService(db.session())\n        workflow_node_execution = rag_pipeline_service.run_draft_workflow_node(\n            pipeline=pipeline, node_id=node_id, user_inputs=inputs, account=current_user\n        )\n\n        if workflow_node_execution is None:\n            raise ValueError(\"Workflow node execution not found\")\n\n        return WorkflowRunNodeExecutionResponse.model_validate(\n            workflow_node_execution, from_attributes=True\n        ).model_dump(mode=\"json\")\n\n\n@console_ns.route(\"/rag/pipelines/<uuid:pipeline_id>/workflow-runs/tasks/<string:task_id>/stop\")\nclass RagPipelineTaskStopApi(Resource):\n    @console_ns.response(200, \"Task stopped successfully\", console_ns.models[SimpleResultResponse.__name__])\n    @setup_required\n    @login_required\n    @edit_permission_required\n    @rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)\n    @account_initialization_required\n    @with_current_user\n    @get_rag_pipeline\n    def post(self, current_user: Account, pipeline: Pipeline, task_id: str):\n        \"\"\"","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py#L482-L518","documentation":"Raised as a raw ValueError when RagPipelineService.run_draft_workflow_node returns None while running a single draft-workflow node (POST /rag/pipelines/<pipeline_id>/workflows/draft/nodes/<node_id>/run). Because it is a plain ValueError rather than a werkzeug HTTPException, Flask surfaces it as an HTTP 500 instead of a meaningful 4xx. The service returns None when no WorkflowNodeExecution record can be produced for the given node.","triggerScenarios":"Calling the run-node endpoint with a node_id that does not exist in the pipeline's current draft workflow, a draft workflow that has not been initialized/synced, or a node type that the runner refuses to execute (so no execution row is persisted). The controller then hits the `if workflow_node_execution is None` branch and raises.","commonSituations":"Frontend 'Run single node' button pointed at a stale node_id after the graph was edited but not saved; running a node before a draft workflow exists for the pipeline; concurrent edits that drop the node; calling the API directly with a copied node_id from a different pipeline.","solutions":["Confirm the node_id still exists in the pipeline's current draft workflow (GET the draft graph) before invoking run.","If you maintain this controller, translate the None branch to raise NotFound(\"Workflow node execution not found\") instead of ValueError so clients get a 404.","Ensure the pipeline has an initialized draft workflow; create/sync the draft before running individual nodes.","Refresh the pipeline editor after graph changes so the client sends the latest node_id."],"exampleFix":"// before\nif workflow_node_execution is None:\n    raise ValueError(\"Workflow node execution not found\")\n// after\nfrom werkzeug.exceptions import NotFound\nif workflow_node_execution is None:\n    raise NotFound(\"Workflow node execution not found\")","handlingStrategy":"validation","validationCode":"// Before calling run, confirm node exists in the current draft\nasync function runNode(pipelineId, nodeId, inputs) {\n  const draft = await fetch(`/rag/pipelines/${pipelineId}/workflows/draft`).then(r => r.json());\n  const exists = JSON.stringify(draft.graph).includes(`\"id\":\"${nodeId}\"`);\n  if (!exists) throw new Error(`node ${nodeId} not in draft workflow`);\n  return fetch(`/rag/pipelines/${pipelineId}/workflows/draft/nodes/${nodeId}/run`, {\n    method: 'POST', headers: {'Content-Type':'application/json'},\n    body: JSON.stringify({ inputs })\n  });\n}","typeGuard":"function isNodeIdInGraph(graph, nodeId) {\n  return Array.isArray(graph?.nodes) && graph.nodes.some(n => n.id === nodeId);\n}","tryCatchPattern":"try {\n  const r = await runNode(pipelineId, nodeId, inputs);\n  if (!r.ok) throw await r.json();\n} catch (e) {\n  // 500 with 'Workflow node execution not found' -> node missing/stale\n  if (e.message?.includes('Workflow node execution not found')) refreshDraft();\n  else throw e;\n}","preventionTips":["Refresh the draft graph after edits and run only node_ids returned by it.","Do not cache node_ids across sessions.","Treat this 500 as 'node not runnable' until the controller is fixed to return 404."],"tags":["rag-pipeline","workflow","backend","http-500"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}