{"record":{"id":"04378bab676a66be","repo":"langgenius/dify","slug":"last-run-not-found","errorCode":null,"errorMessage":"last run not found","messagePattern":"last run not found","errorType":"http","errorClass":"NotFound","httpStatus":404,"severity":"info","filePath":"api/controllers/console/app/workflow.py","lineNumber":1675,"sourceCode":"    @console_ns.response(404, \"Node last run not found\")\n    @console_ns.response(403, \"Permission denied\")\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @rbac_permission_required(RBACResourceScope.APP, RBACPermission.APP_VIEW_LAYOUT)\n    @get_app_model(mode=[AppMode.ADVANCED_CHAT, AppMode.WORKFLOW])\n    def get(self, app_model: App, node_id: str):\n        srv = WorkflowService()\n        workflow = srv.get_draft_workflow(app_model, session=db.session())\n        if not workflow:\n            raise NotFound(\"Workflow not found\")\n        node_exec = srv.get_node_last_run(\n            app_model=app_model,\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(\"/apps/<uuid:app_id>/workflows/draft/trigger/run\")\nclass DraftWorkflowTriggerRunApi(Resource):\n    \"\"\"\n    Full workflow debug - Polling API for trigger events\n    Path: /apps/<uuid:app_id>/workflows/draft/trigger/run\n    \"\"\"\n\n    @console_ns.doc(\"poll_draft_workflow_trigger_run\")\n    @console_ns.doc(description=\"Poll for trigger events and execute full workflow when event arrives\")\n    @console_ns.doc(params={\"app_id\": \"Application ID\"})\n    @console_ns.expect(\n        console_ns.model(\n            \"DraftWorkflowTriggerRunRequest\",\n            {\n                \"node_id\": fields.String(required=True, description=\"Node ID\"),","sourceCodeStart":1657,"sourceCodeEnd":1693,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/workflow.py#L1657-L1693","documentation":"HTTP 404 NotFound('last run not found') raised by DraftWorkflowNodeLastRunApi.get (GET /apps/{app_id}/workflows/draft/nodes/{node_id}/last-run) when WorkflowService.get_node_last_run returns None. The draft workflow exists, but no execution record exists for the given node_id (the node was never run in the debugger).","triggerScenarios":"Polling/reading the last-run result for a node that has never been executed, or whose prior execution record is gone.","commonSituations":"User opens the node inspector before running the node; node_id is wrong/renamed; execution history was cleared.","solutions":["Run the node once (POST .../nodes/{node_id}/run) before fetching its last-run.","Verify the node_id matches a node present in the draft graph.","Treat this 404 as a non-error 'no data yet' state in the UI."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Run the node at least once before fetching its last-run.\nconst lastRun = await safeGetLastRun(appId, nodeId);\nif (!lastRun) await runDraftNode(appId, nodeId);","typeGuard":"const hasLastRun = (r): r is {id: string} => !!r && typeof r.id === 'string';","tryCatchPattern":"try {\n  return await getNodeLastRun(appId, nodeId);\n} catch (e) {\n  if (e?.status === 404 && /last run not found/i.test(e?.message)) {\n    return null; // no data yet — treat as empty state\n  }\n  throw e;\n}","preventionTips":["Treat 'last run not found' as an empty state, not a hard error.","Verify node_id exists in the draft graph before polling.","Run the node once before enabling the last-run panel."],"tags":["workflow","not-found","node-run","last-run","console-api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}