lfnovo/open-notebook · error · HTTPException
Error creating chat session: {str(e)}
Error message
Error creating chat session: {str(e)} What it means
Generic 500 from POST /chat/sessions when session creation fails unexpectedly (not NotFound/HTTP/OpenNotebookError). Original cause is logged as 'Error creating chat session: ...'.
Source
Thrown at api/routers/chat.py:175
return ChatSessionResponse(
id=session.id or "",
title=session.title or "",
notebook_id=request.notebook_id,
created=str(session.created),
updated=str(session.updated),
message_count=0,
model_override=session.model_override,
)
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 creating chat session: {str(e)}")
raise HTTPException(
status_code=500, detail=f"Error creating chat session: {str(e)}"
)
@router.get(
"/chat/sessions/{session_id}", response_model=ChatSessionWithMessagesResponse
)
async def get_session(session_id: str):
"""Get a specific session with its messages."""
try:
# Get session (normalizes the ID and 404s if missing)
full_session_id, session = await get_session_or_404(session_id)
# Get session state from LangGraph to retrieve messages
# Use sync get_state() in a thread since SqliteSaver doesn't support async
thread_state = await asyncio.to_thread(
chat_graph.get_state,
config=RunnableConfig(configurable={"thread_id": full_session_id}),View on GitHub (pinned to a7de90d38a)
Solutions
- Check API logs for the exact underlying exception
- Confirm SurrealDB is up and migrations ran on API startup
- Validate model_override against the configured providers before posting
Defensive patterns
Strategy: retry
Try / catch
catch (e) { if (e.status === 500 && isTransient(e)) retry(); else surfaceError(e); } Prevention
- Validate model_override against provider list first
- Ensure DB migrations have run
When it happens
Trigger: ChatSession.save() failing due to DB connectivity loss, schema constraint violations, or an invalid model_override value rejected at persist time.
Common situations: SurrealDB down or restarted, schema migration didn't run (table definition missing), passing an unsupported model id in model_override.
Related errors
- Error fetching chat sessions: {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/b195c0fb3a827052.
Report an issue: GitHub.