HKUDS/DeepTutor · error · HTTPException

Knowledge base '{kb_name}' not found

Error message

Knowledge base '{kb_name}' not found

What it means

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.

Source

Thrown at deeptutor/api/routers/knowledge.py:778

    requested = str(kb_name or "").strip()
    kb_names = manager.list_knowledge_bases()
    if requested and requested in kb_names:
        return requested

    if requested.lower() in DEFAULT_KB_ALIASES:
        default_kb = manager.get_default()
        if default_kb and default_kb in kb_names:
            return default_kb
        raise HTTPException(status_code=404, detail="No default knowledge base is configured")

    raise HTTPException(status_code=404, detail=f"Knowledge base '{requested}' not found")


def _load_kb_entry_or_404(manager: KnowledgeBaseManager, kb_name: str) -> dict:
    manager.config = manager._load_config()
    kb_entry = manager.config.get("knowledge_bases", {}).get(kb_name)
    if kb_entry is None:
        raise HTTPException(status_code=404, detail=f"Knowledge base '{kb_name}' not found")
    return kb_entry


def _assert_not_connected_kb(kb_name: str, kb_entry: dict) -> None:
    """Block writes to connected KBs (Obsidian vaults, linked indexes).

    They are read-only pointers to the user's external files — we never write
    into or re-index them.
    """
    if is_connected_kb(kb_entry):
        raise HTTPException(
            status_code=409,
            detail=(
                f"Knowledge base '{kb_name}' is connected to an external resource and is "
                "read-only. Local file operations and re-indexing are not available for it."
            ),
        )

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Refresh the KB list in the client before acting on a name
  2. Recreate the KB if it was deleted
  3. Confirm the server's data directory contains the expected knowledge base config
Defensive patterns

Strategy: try-catch

Validate before calling

entry = manager.config.get('knowledge_bases', {}).get(kb_name)
if entry is None: refresh_or_fail_fast(kb_name)

Try / catch

try: operate_on_kb(kb_name)
except HTTPError as e:
    if e.response.status_code == 404 and 'not found' in e.response.text():
        reload_kb_config(); validate_or_abort()

Prevention

When it happens

Trigger: 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.

Common situations: Two tabs/UIs where one deleted the KB; config file replaced or reset (data dir wiped); race between listing and acting on KBs.

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/ed3f30fc65d0b4aa. Report an issue: GitHub.