{"record":{"id":"dd6401ffcef7db74","repo":"langflow-ai/langflow","slug":"graph-not-found","errorCode":null,"errorMessage":"Graph not found","messagePattern":"Graph not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"src/backend/base/langflow/api/v1/chat.py","lineNumber":487,"sourceCode":"        flow_id=flow_id,\n        flow_user_id=flow.user_id,\n        workspace_id=flow.workspace_id,\n        folder_id=flow.folder_id,\n    )\n\n    chat_service = get_chat_service()\n    telemetry_service = get_telemetry_service()\n    flow_id_str = str(flow_id)\n\n    next_runnable_vertices = []\n    top_level_vertices = []\n    start_time = time.perf_counter()\n    error_message = None\n    run_id = None\n    try:\n        graph: Graph = await chat_service.get_cache(flow_id_str)\n    except KeyError as exc:\n        raise HTTPException(status_code=404, detail=\"Graph not found\") from exc\n\n    try:\n        cache = await chat_service.get_cache(flow_id_str)\n        if isinstance(cache, CacheMiss):\n            # If there's no cache\n            await logger.awarning(f\"No cache found for {flow_id_str}. Building graph starting at {vertex_id}\")\n            async with session_scope() as session:\n                graph = await build_graph_from_db(\n                    flow_id=flow_id,\n                    session=session,\n                    chat_service=chat_service,\n                )\n            run_id = str(uuid.uuid4())\n            graph.set_run_id(run_id)\n        else:\n            graph = cache.get(\"result\")\n            await graph.initialize_run()\n            run_id = graph.run_id","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/chat.py#L469-L505","documentation":"Raised as HTTP 404 with detail 'Graph not found' when chat_service.get_cache(flow_id) raises KeyError, meaning there is no compiled Graph in the cache for that flow id. The per-vertex build route requires a prior successful full-flow build to have populated the in-memory graph cache; this early get_cache uses strict KeyError semantics.","triggerScenarios":"Calling POST /build/{flow_id}/vertices/{vertex_id} before any successful POST /build/{flow_id} on that server process, or after a server restart / cache flush that dropped the graph cache.","commonSituations":"Restarting the backend between building the flow and building a single vertex; running multiple workers so the vertex request lands on a worker without the cached graph; cache TTL expiry under load.","solutions":["Run a full flow build (POST /api/v1/chat/build/{flow_id}) first, wait for it to succeed, then build individual vertices.","Pin requests to the same worker in dev (single worker) or use the Redis cache backend so all workers share graph cache.","If the cache was flushed intentionally, re-build the flow before vertex-level calls."],"exampleFix":"// before\nawait client.post(f\"/api/v1/chat/build/{flow_id}/vertices/{vid}\")  # 404 Graph not found\n\n// after\nawait client.post(f\"/api/v1/chat/build/{flow_id}\")  # populate graph cache\nawait client.post(f\"/api/v1/chat/build/{flow_id}/vertices/{vid}\")","handlingStrategy":"validation","validationCode":"# Ensure the graph is cached before vertex-level builds\nbuild = await client.post(f\"/api/v1/chat/build/{flow_id}\")\nbuild.raise_for_status()\n# only now issue per-vertex requests","typeGuard":null,"tryCatchPattern":"try:\n    await client.post(f\"/api/v1/chat/build/{flow_id}/vertices/{vid}\")\nexcept httpx.HTTPStatusError as e:\n    if e.response.status_code == 404 and e.response.json()[\"detail\"] == \"Graph not found\":\n        await client.post(f\"/api/v1/chat/build/{flow_id}\")  # rebuild cache, then retry once\n        return await client.post(f\"/api/v1/chat/build/{flow_id}/vertices/{vid}\")\n    raise","preventionTips":["Always run a full build before per-vertex calls in each server session.","Use the shared (Redis) cache backend in multi-worker setups so any worker has the graph.","Re-build after server restarts; graph cache is in-memory per process."],"tags":["langflow","cache","graph","http-404"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}