{"record":{"id":"1767e165bb0ff81a","repo":"HKUDS/DeepTutor","slug":"failed-to-add-to-category","errorCode":null,"errorMessage":"Failed to add to category","messagePattern":"Failed to add to category","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"deeptutor/api/routers/question_notebook.py","lineNumber":332,"sourceCode":"        payload.entry_ids, payload.category_id, link=payload.link\n    )\n    return {\n        \"changed\": changed,\n        \"requested\": len(payload.entry_ids),\n        \"category_id\": payload.category_id,\n        \"link\": payload.link,\n    }\n\n\n@router.post(\"/entries/{entry_id}/categories\")\nasync def add_entry_to_category(entry_id: int, payload: CategoryAddRequest):\n    store = get_sqlite_session_store()\n    entry = await store.get_notebook_entry(entry_id)\n    if entry is None:\n        raise HTTPException(status_code=404, detail=\"Entry not found\")\n    ok = await store.add_entry_to_category(entry_id, payload.category_id)\n    if not ok:\n        raise HTTPException(status_code=400, detail=\"Failed to add to category\")\n    return {\"added\": True, \"entry_id\": entry_id, \"category_id\": payload.category_id}\n\n\n@router.delete(\"/entries/{entry_id}/categories/{category_id}\")\nasync def remove_entry_from_category(entry_id: int, category_id: int):\n    store = get_sqlite_session_store()\n    removed = await store.remove_entry_from_category(entry_id, category_id)\n    if not removed:\n        raise HTTPException(status_code=404, detail=\"Link not found\")\n    return {\"removed\": True, \"entry_id\": entry_id, \"category_id\": category_id}\n\n\n# ── Overview ─────────────────────────────────────────────────────\n\n\n@router.get(\"/stats\", response_model=QuestionBankStats)\nasync def question_bank_stats() -> QuestionBankStats:\n    \"\"\"Counts behind the filter chips; also the agent's one-call overview.\"\"\"","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/question_notebook.py#L314-L350","documentation":"Error \"Failed to add to category\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/question_notebook.py:332 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}