{"record":{"id":"3996b285d0f4d28f","repo":"HKUDS/DeepTutor","slug":"kb-kb-name-not-found","errorCode":null,"errorMessage":"KB '{kb_name}' not found","messagePattern":"KB '(.+?)' not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":3398,"sourceCode":"    except HTTPException:\n        raise\n    except ValueError as e:\n        raise HTTPException(\n            status_code=400 if \"not found\" not in str(e).lower() else 404, detail=str(e)\n        )\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.get(\"/{kb_name}/github-sources\", response_model=list[GitHubSourceInfo])\nasync def get_github_sources(kb_name: str):\n    try:\n        manager, resolved_name, _ = _writable_kb(kb_name)\n        return [GitHubSourceInfo(**s) for s in manager.get_github_sources(resolved_name)]\n    except HTTPException:\n        raise\n    except ValueError:\n        raise HTTPException(status_code=404, detail=f\"KB '{kb_name}' not found\")\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.delete(\"/{kb_name}/github-source/{source_id}\")\nasync def remove_github_source(kb_name: str, source_id: str):\n    try:\n        manager, resolved_name, _ = _writable_kb(kb_name)\n        if not manager.remove_github_source(resolved_name, source_id):\n            raise HTTPException(status_code=404, detail=f\"Source '{source_id}' not found\")\n        return {\"message\": \"Removed\", \"source_id\": source_id}\n    except HTTPException:\n        raise\n    except ValueError:\n        raise HTTPException(status_code=404, detail=f\"KB '{kb_name}' not found\")\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n","sourceCodeStart":3380,"sourceCodeEnd":3416,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L3380-L3416","documentation":"HTTP 404 from GET /{kb_name}/github-sources when manager.get_github_sources (or _writable_kb) raises ValueError — the named knowledge base does not exist in the manager's scope.","triggerScenarios":"Listing GitHub sources for a misspelled, deleted, or unresolvable kb_name; _writable_kb raises ValueError before sources can be fetched.","commonSituations":"Client holds a stale KB name after rename; KB created in a different manager/namespace; deleted KB still referenced in bookmarks/scripts.","solutions":["Fetch the KB list and use the exact current name","Recreate the KB if it was deleted and re-add its GitHub sources","Normalize/resolve KB aliases client-side before calling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"kb_names = {k['name'] for k in client.get('/api/v1/knowledge').json()}\nassert kb_name in kb_names","typeGuard":null,"tryCatchPattern":"try:\n    sources = client.get(f'/api/v1/knowledge/{kb}/github-sources')\nexcept HTTPError as e:\n    if e.response.status_code == 404: return []\n    raise","preventionTips":["Derive kb_name from the current KB list","Show an empty sources panel on 404 rather than an error toast","Handle KB renames by re-resolving names"],"tags":["github-source","knowledge-base","http-404"],"backgroundTag":"resource-not-found","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}