{"record":{"id":"5d52ea6169244b88","repo":"wandb/openui","slug":"no-session-found","errorCode":null,"errorMessage":"No session found","messagePattern":"No session found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"backend/openui/server.py","lineNumber":493,"sourceCode":"            except IntegrityError:\n                user = User.get(User.username == getpass.getuser())\n                user_id = user.id\n            if user.email is None:\n                user.email = get_git_user_email()\n                user.save()\n            request.session[\"user_id\"] = str(user_id)\n            session_store.write(\n                request.session[\"session_id\"],\n                str(user_id),\n                SessionData(\n                    username=user.username,\n                    token_count=0,\n                    max_tokens=config.MAX_TOKENS,\n                    email=user.email,\n                ),\n            )\n        else:\n            raise HTTPException(status_code=404, detail=\"No session found\")\n    session_data = session_store.get(session_id)\n    return JSONResponse(\n        content=session_data.model_dump(),\n        status_code=200,\n    )\n\n\n@router.delete(\n    \"/v1/session\",\n    tags=[\"openui/session\"],\n)\nasync def delete_session(\n    request: Request,\n):\n    session_id = request.session.get(\"session_id\")\n    if session_id is None:\n        raise HTTPException(status_code=404, detail=\"No session found\")\n    request.session.pop(\"session_id\")","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/wandb/openui/blob/42d7ab4ab6650433486dfb12eb3783c393a3e475/backend/openui/server.py#L475-L511","documentation":"Raised by OpenUI's GET session endpoint: the handler can identify the logged-in user but no session record matching the requested session exists (the else branch before falling back to session_store), so it returns HTTP 404 'No session found'. It signals the requested session id is unknown or was never persisted.","triggerScenarios":"GETting a session whose id exists in neither the database (User's associated session) nor the in-memory session_store — e.g. requesting a session id that was never created, belongs to another user, or was created before a server restart wiped the in-memory store.","commonSituations":"Client bookmarks/caches an old session id after server restart (session_store is memory-resident), sharing session ids across users, or a race where the session row was deleted while the client still holds the id.","solutions":["Create a new session (POST the session endpoint) and use the returned session id instead of the stale one.","If your deployment relies on session_store, add persistent storage (e.g. Redis) or expect loss on restart.","Verify the request's authenticated user actually owns the requested session id.","Handle 404 in the client by resetting local session state and re-initializing."],"exampleFix":"// before\nconst res = await fetch(`/session/${oldId}`); // 404 after restart\n// after\nlet res = await fetch(`/session/${oldId}`);\nif (res.status === 404) {\n  res = await fetch('/session', { method: 'POST' }); // create new session\n}","handlingStrategy":"fallback","validationCode":"const res = await fetch(`/session/${sessionId}`);\nif (res.status === 404) {\n  sessionId = null; // invalidate local reference\n  const created = await fetch(\"/session\", { method: \"POST\" });\n  sessionId = (await created.json()).id;\n}","typeGuard":"function hasSession(state): state is State & { sessionId: string } {\n  return typeof state.sessionId === \"string\" && state.sessionId.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Don't persist session ids across server restarts unless the store is persistent","Back session_store with Redis or the DB for durability","Re-fetch or recreate sessions on any 404 instead of retrying the same id","Scope session ids to the owning user and validate ownership before use"],"tags":["http-404","session","state-management","fastapi"],"backgroundTag":"session-not-found","analyzedSha":"42d7ab4ab6650433486dfb12eb3783c393a3e475","analyzedAt":"2026-09-01T05:00:32.200Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}