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

  1. Read the API log line 'Error fetching session: ...' for the root cause
  2. Inspect that session's messages in SurrealDB for null/corrupt fields
  3. 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

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


AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27). Data as JSON: /api/errors/547832c319f32745. Report an issue: GitHub.