HKUDS/DeepTutor · error · HTTPException
KB '{kb_name}' not found
Error message
KB '{kb_name}' not found What it means
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.
Source
Thrown at deeptutor/api/routers/knowledge.py:3398
except HTTPException:
raise
except ValueError as e:
raise HTTPException(
status_code=400 if "not found" not in str(e).lower() else 404, detail=str(e)
)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@router.get("/{kb_name}/github-sources", response_model=list[GitHubSourceInfo])
async def get_github_sources(kb_name: str):
try:
manager, resolved_name, _ = _writable_kb(kb_name)
return [GitHubSourceInfo(**s) for s in manager.get_github_sources(resolved_name)]
except HTTPException:
raise
except ValueError:
raise HTTPException(status_code=404, detail=f"KB '{kb_name}' not found")
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@router.delete("/{kb_name}/github-source/{source_id}")
async def remove_github_source(kb_name: str, source_id: str):
try:
manager, resolved_name, _ = _writable_kb(kb_name)
if not manager.remove_github_source(resolved_name, source_id):
raise HTTPException(status_code=404, detail=f"Source '{source_id}' not found")
return {"message": "Removed", "source_id": source_id}
except HTTPException:
raise
except ValueError:
raise HTTPException(status_code=404, detail=f"KB '{kb_name}' not found")
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
View on GitHub (pinned to 3e82f13042)
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
Defensive patterns
Strategy: validation
Validate before calling
kb_names = {k['name'] for k in client.get('/api/v1/knowledge').json()}
assert kb_name in kb_names Try / catch
try:
sources = client.get(f'/api/v1/knowledge/{kb}/github-sources')
except HTTPError as e:
if e.response.status_code == 404: return []
raise Prevention
- 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
When it happens
Trigger: Listing GitHub sources for a misspelled, deleted, or unresolvable kb_name; _writable_kb raises ValueError before sources can be fetched.
Common situations: Client holds a stale KB name after rename; KB created in a different manager/namespace; deleted KB still referenced in bookmarks/scripts.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Source '{source_id}' not found
- No default knowledge base is configured
- Knowledge base '{requested}' not found
- Knowledge base '{kb_name}' not found
- Folder '{folder_id}' not found
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/3996b285d0f4d28f.
Report an issue: GitHub.