{"record":{"id":"0dd93078ba58761d","repo":"langgenius/dify","slug":"last-run-not-found-0dd930","errorCode":null,"errorMessage":"last run not found","messagePattern":"last run not found","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"warning","filePath":"api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py","lineNumber":1012,"sourceCode":"        \"Node last run retrieved successfully\",\n        console_ns.models[WorkflowRunNodeExecutionResponse.__name__],\n    )\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @get_rag_pipeline\n    def get(self, pipeline: Pipeline, node_id: str):\n        rag_pipeline_service = RagPipelineService(db.session())\n        workflow = rag_pipeline_service.get_draft_workflow(pipeline=pipeline)\n        if not workflow:\n            raise NotFound(\"Workflow not found\")\n        node_exec = rag_pipeline_service.get_node_last_run(\n            pipeline=pipeline,\n            workflow=workflow,\n            node_id=node_id,\n        )\n        if node_exec is None:\n            raise NotFound(\"last run not found\")\n        return WorkflowRunNodeExecutionResponse.model_validate(node_exec, from_attributes=True).model_dump(mode=\"json\")\n\n\n@console_ns.route(\"/rag/pipelines/transform/datasets/<uuid:dataset_id>\")\nclass RagPipelineTransformApi(Resource):\n    @console_ns.response(200, \"Success\", console_ns.models[RagPipelineOpaqueResponse.__name__])\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @with_current_user\n    @with_session\n    def post(self, session: Session, current_user: Account, dataset_id: UUID):\n        if not (current_user.has_edit_permission or current_user.is_dataset_operator):\n            raise Forbidden()\n\n        dataset_id_str = str(dataset_id)\n        rag_pipeline_transform_service = RagPipelineTransformService()\n        result = rag_pipeline_transform_service.transform_dataset(dataset_id_str, session)","sourceCodeStart":994,"sourceCodeEnd":1030,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py#L994-L1030","documentation":"Raised as NotFound(\"last run not found\") (HTTP 404) in RagPipelineWorkflowLastRunApi.get after the draft workflow is found but get_node_last_run returns None. It means the node exists in the draft context but has never produced an execution record, so there is no 'last run' to return.","triggerScenarios":"Calling GET .../workflows/draft/nodes/<node_id>/last-run for a node that has never been executed (newly added node, draft saved but never run), or whose execution records were purged. The draft workflow resolves fine, but node_exec is None.","commonSituations":"Requesting last-run right after adding a node to the graph; node is an input/trigger type that does not create execution rows; executions cleaned up by retention.","solutions":["Run the node first (POST .../draft/nodes/<node_id>/run) before asking for its last run.","Treat this 404 as 'node has no execution history' in the UI rather than an error.","Confirm node_id belongs to an executable node type.","If history is expected, check retention/cleanup settings that may have removed old executions."],"exampleFix":"// before\nGET .../draft/nodes/<node>/last-run   // -> 404 last run not found\n// after\nawait POST .../draft/nodes/<node>/run\nGET .../draft/nodes/<node>/last-run","handlingStrategy":"try-catch","validationCode":"async function getLastRunOrCreate(pipelineId, nodeId, inputs) {\n  const r = await fetch(`/rag/pipelines/${pipelineId}/workflows/draft/nodes/${nodeId}/last-run`);\n  if (r.status === 404) {\n    await fetch(`/rag/pipelines/${pipelineId}/workflows/draft/nodes/${nodeId}/run`, { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ inputs }) });\n    return fetch(`/rag/pipelines/${pipelineId}/workflows/draft/nodes/${nodeId}/last-run`);\n  }\n  return r;\n}","typeGuard":"function hasExecutionHistory(exec) { return !!exec && !!exec.id; }","tryCatchPattern":"try { return await getLastRunOrCreate(id, nodeId, inputs); } catch (e) { /* 'last run not found' handled by run-first fallback */ throw e; }","preventionTips":["Run the node at least once before asking for last-run.","Treat 'last run not found' as 'no history', not a hard error.","Confirm the node type produces execution rows."],"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"}