HKUDS/DeepTutor · error · HTTPException
Message not found
Error message
Message not found
What it means
Post-deletion guard in delete_turn_by_message: the session existed but the store could not delete the turn because message_id maps to no message in it (result['deleted'] falsy), reported as 404.
Solutions
- Fetch the session's messages to confirm the message_id before deleting
- Treat 404 on delete as idempotent success during cleanups
- Ensure the message_id is from the same session — ids from other sessions will not resolve
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/api/routers/sessions.py:202 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/9391a95aee9c14a7.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/sessions.py:202
raise HTTPException(status_code=404, detail="Session not found")
updated = await store.update_session_preferences(
session_id, {"selected_branches": dict(payload.selected_branches)}
)
if not updated:
raise HTTPException(status_code=404, detail="Session not found")
return {"selected_branches": payload.selected_branches}
@router.delete("/{session_id}/messages/{message_id}")
async def delete_turn_by_message(session_id: str, message_id: int):
store = get_sqlite_session_store()
result = await store.delete_turn_by_message(session_id, message_id)
if result["was_running"]:
raise HTTPException(
status_code=409, detail="Cannot delete a message while its turn is running"
)
if not result["deleted"]:
raise HTTPException(status_code=404, detail="Message not found")
attachment_store = get_attachment_store()
for aid in result["attachment_ids"]:
try:
await attachment_store.delete_attachment(session_id, aid)
except Exception:
logger.exception("failed to delete attachment %s for session %s", aid, session_id)
return result
@router.post("/{session_id}/quiz-results")
async def record_quiz_results(session_id: str, payload: QuizResultsRequest):
if not payload.answers:
raise HTTPException(status_code=400, detail="Quiz results are required")
store = get_sqlite_session_store()
session = await store.get_session(session_id)
if session is None:
raise HTTPException(status_code=404, detail="Session not found")
content = _format_quiz_results_message(payload.answers)View on GitHub (pinned to 3e82f13042)