{"record":{"id":"6d1147e90f45f7cd","repo":"lfnovo/open-notebook","slug":"session-not-found-6d1147","errorCode":null,"errorMessage":"Session not found","messagePattern":"Session not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"api/routers/chat.py","lineNumber":226,"sourceCode":"\n        if not notebook_id:\n            # This might be an old session created before API migration\n            logger.warning(\n                f\"No notebook relationship found for session {session_id} - may be an orphaned session\"\n            )\n\n        return ChatSessionWithMessagesResponse(\n            id=session.id or \"\",\n            title=session.title or \"Untitled Session\",\n            notebook_id=notebook_id,\n            created=str(session.created),\n            updated=str(session.updated),\n            message_count=len(messages),\n            messages=messages,\n            model_override=getattr(session, \"model_override\", None),\n        )\n    except NotFoundError:\n        raise HTTPException(status_code=404, detail=\"Session not found\")\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error fetching session: {str(e)}\")\n        raise HTTPException(status_code=500, detail=f\"Error fetching session: {str(e)}\")\n\n\n@router.put(\"/chat/sessions/{session_id}\", response_model=ChatSessionResponse)\nasync def update_session(session_id: str, request: UpdateSessionRequest):\n    \"\"\"Update session title.\"\"\"\n    try:\n        # Get session (normalizes the ID and 404s if missing)\n        full_session_id, session = await get_session_or_404(session_id)\n\n        update_data = request.model_dump(exclude_unset=True)\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/chat.py#L208-L244","documentation":"404 from GET /chat/sessions/{session_id} when the session lookup raises NotFoundError — the chat session id does not exist (or its full-id resolution failed).","triggerScenarios":"Fetching a session id that was deleted, from another DB, or a partial id that cannot be resolved to a full record id.","commonSituations":"User deleted the session in another tab; frontend holds a stale session list; SurrealDB was reset losing session rows.","solutions":["Refresh the session list (GET /chat/sessions) and use a current id","Verify the session id is passed whole (not truncated by URL encoding)","Confirm the API points at the SurrealDB instance that created the session"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const s = await fetch(`/api/chat/sessions/${id}`);\nif (s.status === 404) removeFromLocalList(id);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sync session list after deletions","URL-encode session ids intact"],"tags":["http-404","not-found","chat-session"],"backgroundTag":"resource-not-found","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}