lfnovo/open-notebook · error · HTTPException
Session not found
Error message
Session not found
What it means
404 from GET /chat/sessions/{session_id} when the session lookup raises NotFoundError — the chat session id does not exist (or its full-id resolution failed).
Source
Thrown at api/routers/chat.py:226
if not notebook_id:
# This might be an old session created before API migration
logger.warning(
f"No notebook relationship found for session {session_id} - may be an orphaned session"
)
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)
View on GitHub (pinned to a7de90d38a)
Solutions
- Refresh the session list (GET /chat/sessions) and use a current id
- Verify the session id is passed whole (not truncated by URL encoding)
- Confirm the API points at the SurrealDB instance that created the session
Defensive patterns
Strategy: validation
Validate before calling
const s = await fetch(`/api/chat/sessions/${id}`);
if (s.status === 404) removeFromLocalList(id); Prevention
- Sync session list after deletions
- URL-encode session ids intact
When it happens
Trigger: Fetching a session id that was deleted, from another DB, or a partial id that cannot be resolved to a full record id.
Common situations: User deleted the session in another tab; frontend holds a stale session list; SurrealDB was reset losing session rows.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Credential not found
- {embed_request.item_type} not found
- Rebuild command not found
- Episode profile '{profile_name}' not found
- Episode profile '{profile_id}' not found
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/6d1147e90f45f7cd.
Report an issue: GitHub.