{"record":{"id":"ed3f30fc65d0b4aa","repo":"HKUDS/DeepTutor","slug":"knowledge-base-kb-name-not-found","errorCode":null,"errorMessage":"Knowledge base '{kb_name}' not found","messagePattern":"Knowledge base '(.+?)' not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":778,"sourceCode":"    requested = str(kb_name or \"\").strip()\n    kb_names = manager.list_knowledge_bases()\n    if requested and requested in kb_names:\n        return requested\n\n    if requested.lower() in DEFAULT_KB_ALIASES:\n        default_kb = manager.get_default()\n        if default_kb and default_kb in kb_names:\n            return default_kb\n        raise HTTPException(status_code=404, detail=\"No default knowledge base is configured\")\n\n    raise HTTPException(status_code=404, detail=f\"Knowledge base '{requested}' not found\")\n\n\ndef _load_kb_entry_or_404(manager: KnowledgeBaseManager, kb_name: str) -> dict:\n    manager.config = manager._load_config()\n    kb_entry = manager.config.get(\"knowledge_bases\", {}).get(kb_name)\n    if kb_entry is None:\n        raise HTTPException(status_code=404, detail=f\"Knowledge base '{kb_name}' not found\")\n    return kb_entry\n\n\ndef _assert_not_connected_kb(kb_name: str, kb_entry: dict) -> None:\n    \"\"\"Block writes to connected KBs (Obsidian vaults, linked indexes).\n\n    They are read-only pointers to the user's external files — we never write\n    into or re-index them.\n    \"\"\"\n    if is_connected_kb(kb_entry):\n        raise HTTPException(\n            status_code=409,\n            detail=(\n                f\"Knowledge base '{kb_name}' is connected to an external resource and is \"\n                \"read-only. Local file operations and re-indexing are not available for it.\"\n            ),\n        )\n","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L760-L796","documentation":"Raised by _load_kb_entry_or_404 after reloading the manager config: the named KB has no entry in config['knowledge_bases']. It is the lower-level loader used by folder/move/delete/upload/reindex handlers. HTTP 404.","triggerScenarios":"Any folder/file/upload/reindex operation whose kb_name is absent from the freshly-loaded config — stale name, deleted KB, or name resolved from an outdated client-side cache.","commonSituations":"Two tabs/UIs where one deleted the KB; config file replaced or reset (data dir wiped); race between listing and acting on KBs.","solutions":["Refresh the KB list in the client before acting on a name","Recreate the KB if it was deleted","Confirm the server's data directory contains the expected knowledge base config"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"entry = manager.config.get('knowledge_bases', {}).get(kb_name)\nif entry is None: refresh_or_fail_fast(kb_name)","typeGuard":null,"tryCatchPattern":"try: operate_on_kb(kb_name)\nexcept HTTPError as e:\n    if e.response.status_code == 404 and 'not found' in e.response.text():\n        reload_kb_config(); validate_or_abort()","preventionTips":["Reload config before each batch of KB operations","Guard against concurrent KB deletion with a re-check-and-retry loop"],"tags":["knowledge-base","not-found","stale-state","http-404"],"backgroundTag":"resource-not-found","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}