lfnovo/open-notebook · error · HTTPException
Error fetching chat sessions: {str(e)}
Error message
Error fetching chat sessions: {str(e)} What it means
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.
Source
Thrown at api/routers/chat.py:133
title=session.title or "Untitled Session",
notebook_id=notebook_id,
created=str(session.created),
updated=str(session.updated),
message_count=msg_count,
model_override=getattr(session, "model_override", None),
)
)
return results
except NotFoundError:
raise HTTPException(status_code=404, detail="Notebook not found")
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error fetching chat sessions: {str(e)}")
raise HTTPException(
status_code=500, detail=f"Error fetching chat sessions: {str(e)}"
)
@router.post("/chat/sessions", response_model=ChatSessionResponse)
async def create_session(request: CreateSessionRequest):
"""Create a new chat session."""
try:
# Verify notebook exists
notebook = await Notebook.get(request.notebook_id)
if not notebook:
raise HTTPException(status_code=404, detail="Notebook not found")
# Create new session
session = ChatSession(
title=request.title
or f"Chat Session {asyncio.get_event_loop().time():.0f}",
model_override=request.model_override,View on GitHub (pinned to a7de90d38a)
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
Defensive patterns
Strategy: retry
Try / catch
catch (e) { if (e.status === 500) { await sleep(1000); retryOnce(); } else throw e; } Prevention
- Watch API logs for the embedded root cause
- Keep SurrealDB healthy before paginating sessions
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error creating chat session: {str(e)}
- Error fetching session: {str(e)}
- Error deleting session: {str(e)}
- Error updating session: {str(e)}
- Error building context: {str(e)}
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/399a51d80867841e.
Report an issue: GitHub.