{"record":{"id":"9def6226653cc0c9","repo":"HKUDS/DeepTutor","slug":"category-not-found","errorCode":null,"errorMessage":"Category not found","messagePattern":"Category not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"deeptutor/api/routers/question_notebook.py","lineNumber":381,"sourceCode":"\n@router.post(\"/categories\", response_model=CategoryItem, status_code=201)\nasync def create_category(payload: CategoryCreateRequest):\n    store = get_sqlite_session_store()\n    try:\n        return await store.create_category(payload.name)\n    except ValueError as exc:\n        raise HTTPException(status_code=409, detail=str(exc))\n\n\n@router.patch(\"/categories/{category_id}\")\nasync def rename_category(category_id: int, payload: CategoryRenameRequest):\n    store = get_sqlite_session_store()\n    try:\n        updated = await store.rename_category(category_id, payload.name)\n    except ValueError as exc:\n        raise HTTPException(status_code=409, detail=str(exc))\n    if not updated:\n        raise HTTPException(status_code=404, detail=\"Category not found\")\n    return {\"updated\": True, \"id\": category_id, \"name\": payload.name}\n\n\n@router.delete(\"/categories/{category_id}\")\nasync def delete_category(category_id: int):\n    store = get_sqlite_session_store()\n    deleted = await store.delete_category(category_id)\n    if not deleted:\n        raise HTTPException(status_code=404, detail=\"Category not found\")\n    return {\"deleted\": True, \"id\": category_id}\n","sourceCodeStart":363,"sourceCodeEnd":392,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/question_notebook.py#L363-L392","documentation":"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.","triggerScenarios":"Thrown at deeptutor/api/routers/question_notebook.py:381 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","contentChangedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}