langflow-ai/langflow · error · HTTPException
Graph not found
Error message
Graph not found
What it means
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.
Source
Thrown at src/backend/base/langflow/api/v1/chat.py:487
flow_id=flow_id,
flow_user_id=flow.user_id,
workspace_id=flow.workspace_id,
folder_id=flow.folder_id,
)
chat_service = get_chat_service()
telemetry_service = get_telemetry_service()
flow_id_str = str(flow_id)
next_runnable_vertices = []
top_level_vertices = []
start_time = time.perf_counter()
error_message = None
run_id = None
try:
graph: Graph = await chat_service.get_cache(flow_id_str)
except KeyError as exc:
raise HTTPException(status_code=404, detail="Graph not found") from exc
try:
cache = await chat_service.get_cache(flow_id_str)
if isinstance(cache, CacheMiss):
# If there's no cache
await logger.awarning(f"No cache found for {flow_id_str}. Building graph starting at {vertex_id}")
async with session_scope() as session:
graph = await build_graph_from_db(
flow_id=flow_id,
session=session,
chat_service=chat_service,
)
run_id = str(uuid.uuid4())
graph.set_run_id(run_id)
else:
graph = cache.get("result")
await graph.initialize_run()
run_id = graph.run_idView on GitHub (pinned to 976ec789d2)
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.
Example fix
// before
await client.post(f"/api/v1/chat/build/{flow_id}/vertices/{vid}") # 404 Graph not found
// after
await client.post(f"/api/v1/chat/build/{flow_id}") # populate graph cache
await client.post(f"/api/v1/chat/build/{flow_id}/vertices/{vid}") Defensive patterns
Strategy: validation
Validate before calling
# Ensure the graph is cached before vertex-level builds
build = await client.post(f"/api/v1/chat/build/{flow_id}")
build.raise_for_status()
# only now issue per-vertex requests Try / catch
try:
await client.post(f"/api/v1/chat/build/{flow_id}/vertices/{vid}")
except httpx.HTTPStatusError as e:
if e.response.status_code == 404 and e.response.json()["detail"] == "Graph not found":
await client.post(f"/api/v1/chat/build/{flow_id}") # rebuild cache, then retry once
return await client.post(f"/api/v1/chat/build/{flow_id}/vertices/{vid}")
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Job not found: {exc!s}
- Job not found
- Ingestion run not found.
- Knowledge bases not found: {}
- No ingestion job found for the knowledge base {kb_name}
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/dd6401ffcef7db74.
Report an issue: GitHub.