HKUDS/DeepTutor · error · HTTPException

KB ' ' not found

Error message

KB '{kb_name}' not found

What it means

Not-found guard (404) raised when a route resolves the requested kb_name and no knowledge base with that name exists in the active manager/base directory. It is the terminal case of the ValueError-style resolution path ('not found' in the message maps to 404 rather than 400) and indicates a stale or mistyped KB reference from the client.

Solutions

  1. List available knowledge bases to confirm the exact name
  2. Correct the kb_name in the request
  3. Re-create the KB if it was deleted on disk
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

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


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/3996b285d0f4d28f. Report an issue: GitHub.

Appendix: 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)