odysseus-dev/odysseus · warning · HTTPException
Session '{session_id}' not found
Error message
Session '{session_id}' not found What it means
HTTP 404 from the paginated history branch of GET /api/session/{session_id}/history: the session passes the owner check but no DbSession row with that id exists, so server-side persisted history cannot be served. Note the owner verification ran first (it consults session_manager), so this specifically means 'not in the database'.
Source
Thrown at routes/history/history_routes.py:154
if meta:
entry["metadata"] = meta
return entry
@router.get("/api/history/{session_id}")
async def get_session_history(
request: Request,
session_id: str,
limit: Optional[int] = None,
offset: Optional[int] = None,
) -> Dict[str, Any]:
_verify_session_owner(request, session_id)
if limit is not None:
page_limit = max(1, min(int(limit), 100))
db = SessionLocal()
try:
db_session = db.query(DbSession).filter(DbSession.id == session_id).first()
if db_session is None:
raise HTTPException(404, f"Session '{session_id}' not found")
total = (
db.query(DbChatMessage)
.filter(DbChatMessage.session_id == session_id)
.count()
)
page_offset = int(offset) if offset is not None else max(total - page_limit, 0)
page_offset = max(0, min(page_offset, total))
# Keep display pagination page-scoped. ``get_session`` is the
# full model-context hydration seam and must not be entered here.
rows = (
db.query(DbChatMessage)
.filter(DbChatMessage.session_id == session_id)
.order_by(DbChatMessage.timestamp)
.offset(page_offset)
.limit(page_limit)
.all()
)View on GitHub (pinned to f9235ebbf1)
Solutions
- Confirm the session was persisted (it should appear via the session list endpoint)
- Check the DB connection / database file the server uses matches the one that stored the session
- Create a new session if the old data is genuinely gone
Defensive patterns
Strategy: validation
Validate before calling
def session_in_db(session_id: str) -> bool:
r = requests.get(f'{base}/api/sessions', headers=hdrs, timeout=30)
return any(s.get('id') == session_id for s in r.json().get('sessions', r.json())) Prevention
- Prefer the DB-backed paginated history call (?limit=N) when persistence matters
- Verify the server points at the intended database file before blaming missing sessions
- After DB resets/migrations, invalidate cached session ids in clients
When it happens
Trigger: GET /api/session/{id}/history?limit=20 for a session that exists only in memory (never persisted), was deleted from the DB, or whose ID came from a different deployment/database.
Common situations: In-memory-only sessions when DB persistence is disabled; database file wiped or migrated; pointing the client at a fresh server instance with an old session list.
Related errors
AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14).
Data as JSON: /api/errors/2d27daa74d16733c.
Report an issue: GitHub.