HKUDS/DeepTutor · error · HTTPException
Category not found
Error message
Category not found
What it means
Raised when a category operation (rename, delete, link) targets a category_id that does not exist in the store; the row lookup failed and the route reports the missing entity rather than acting on a stale id.
Solutions
- Refresh the category list and retry with a current category_id
- Delete links referencing the category before deleting the category itself
- Return the offending category_id in the error payload to speed client-side cleanup
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/api/routers/question_notebook.py:381 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/9def6226653cc0c9.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/question_notebook.py:381
@router.post("/categories", response_model=CategoryItem, status_code=201)
async def create_category(payload: CategoryCreateRequest):
store = get_sqlite_session_store()
try:
return await store.create_category(payload.name)
except ValueError as exc:
raise HTTPException(status_code=409, detail=str(exc))
@router.patch("/categories/{category_id}")
async def rename_category(category_id: int, payload: CategoryRenameRequest):
store = get_sqlite_session_store()
try:
updated = await store.rename_category(category_id, payload.name)
except ValueError as exc:
raise HTTPException(status_code=409, detail=str(exc))
if not updated:
raise HTTPException(status_code=404, detail="Category not found")
return {"updated": True, "id": category_id, "name": payload.name}
@router.delete("/categories/{category_id}")
async def delete_category(category_id: int):
store = get_sqlite_session_store()
deleted = await store.delete_category(category_id)
if not deleted:
raise HTTPException(status_code=404, detail="Category not found")
return {"deleted": True, "id": category_id}
View on GitHub (pinned to 3e82f13042)