lfnovo/open-notebook · error · HTTPException
Error fetching session: {str(e)}
Error message
Error fetching session: {str(e)} What it means
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: ...'.
Source
Thrown at api/routers/chat.py:233
return ChatSessionWithMessagesResponse(
id=session.id or "",
title=session.title or "Untitled Session",
notebook_id=notebook_id,
created=str(session.created),
updated=str(session.updated),
message_count=len(messages),
messages=messages,
model_override=getattr(session, "model_override", None),
)
except NotFoundError:
raise HTTPException(status_code=404, detail="Session not found")
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error fetching session: {str(e)}")
raise HTTPException(status_code=500, detail=f"Error fetching session: {str(e)}")
@router.put("/chat/sessions/{session_id}", response_model=ChatSessionResponse)
async def update_session(session_id: str, request: UpdateSessionRequest):
"""Update session title."""
try:
# Get session (normalizes the ID and 404s if missing)
full_session_id, session = await get_session_or_404(session_id)
update_data = request.model_dump(exclude_unset=True)
if "title" in update_data:
session.title = update_data["title"]
if "model_override" in update_data:
session.model_override = update_data["model_override"]
await session.save()View on GitHub (pinned to a7de90d38a)
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
Defensive patterns
Strategy: retry
Try / catch
catch (e) { if (e.status === 500) showRetryToast(); else throw e; } Prevention
- Monitor API logs for serialization root cause
- Avoid schema drift by running migrations
When it happens
Trigger: Message rows with malformed structure during extract/serialization, DB connection failure mid-query, or datetime conversion errors on created/updated fields.
Common situations: Sessions written by an older app version with different message schema; SurrealDB restart during the request.
Related errors
- Error fetching chat sessions: {str(e)}
- Error creating chat session: {str(e)}
- Error updating session: {str(e)}
- Error deleting session: {str(e)}
- Error building context: {str(e)}
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/547832c319f32745.
Report an issue: GitHub.