{"record":{"id":"547832c319f32745","repo":"lfnovo/open-notebook","slug":"error-fetching-session-str-e","errorCode":null,"errorMessage":"Error fetching session: {str(e)}","messagePattern":"Error fetching session: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/chat.py","lineNumber":233,"sourceCode":"        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\n        if \"title\" in update_data:\n            session.title = update_data[\"title\"]\n\n        if \"model_override\" in update_data:\n            session.model_override = update_data[\"model_override\"]\n\n        await session.save()","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/chat.py#L215-L251","documentation":"Generic 500 from GET /chat/sessions/{session_id} when loading the session or its messages throws an unexpected exception. Cause logged as 'Error fetching session: ...'.","triggerScenarios":"Message rows with malformed structure during extract/serialization, DB connection failure mid-query, or datetime conversion errors on created/updated fields.","commonSituations":"Sessions written by an older app version with different message schema; SurrealDB restart during the request.","solutions":["Read the API log line 'Error fetching session: ...' for the root cause","Inspect that session's messages in SurrealDB for null/corrupt fields","Restart SurrealDB/API if the cause is transient connectivity"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (e.status === 500) showRetryToast(); else throw e; }","preventionTips":["Monitor API logs for serialization root cause","Avoid schema drift by running migrations"],"tags":["http-500","internal-error","chat-session","surrealdb"],"backgroundTag":"unhandled-server-exception","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}