{"record":{"id":"399a51d80867841e","repo":"lfnovo/open-notebook","slug":"error-fetching-chat-sessions-str-e","errorCode":null,"errorMessage":"Error fetching chat sessions: {str(e)}","messagePattern":"Error fetching chat sessions: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/chat.py","lineNumber":133,"sourceCode":"                    title=session.title or \"Untitled Session\",\n                    notebook_id=notebook_id,\n                    created=str(session.created),\n                    updated=str(session.updated),\n                    message_count=msg_count,\n                    model_override=getattr(session, \"model_override\", None),\n                )\n            )\n\n        return results\n    except NotFoundError:\n        raise HTTPException(status_code=404, detail=\"Notebook not found\")\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error fetching chat sessions: {str(e)}\")\n        raise HTTPException(\n            status_code=500, detail=f\"Error fetching chat sessions: {str(e)}\"\n        )\n\n\n@router.post(\"/chat/sessions\", response_model=ChatSessionResponse)\nasync def create_session(request: CreateSessionRequest):\n    \"\"\"Create a new chat session.\"\"\"\n    try:\n        # Verify notebook exists\n        notebook = await Notebook.get(request.notebook_id)\n        if not notebook:\n            raise HTTPException(status_code=404, detail=\"Notebook not found\")\n\n        # Create new session\n        session = ChatSession(\n            title=request.title\n            or f\"Chat Session {asyncio.get_event_loop().time():.0f}\",\n            model_override=request.model_override,","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/chat.py#L115-L151","documentation":"Generic 500 from GET /chat/sessions when an unexpected exception escapes while listing chat sessions (anything that is not NotFoundError, HTTPException, or OpenNotebookError). The original exception is logged with the message embedded in the detail.","triggerScenarios":"SurrealDB connection dropped mid-query, a ChatSession row with corrupted/missing fields (e.g. created/updated not parseable), or a serialization error while building the response models.","commonSituations":"SurrealDB restarted or was never started (make database missing), schema drift after migrations, or records written by an older version missing model_override/created fields.","solutions":["Check the API logs: the full exception string is logged as 'Error fetching chat sessions: ...'","Verify SurrealDB is running and the API can reach it (make status)","Inspect the chat_session records in SurrealDB for null/missing fields and delete or fix malformed rows"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (e.status === 500) { await sleep(1000); retryOnce(); } else throw e; }","preventionTips":["Watch API logs for the embedded root cause","Keep SurrealDB healthy before paginating sessions"],"tags":["http-500","internal-error","surrealdb","chat-sessions"],"backgroundTag":"unhandled-server-exception","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}