HKUDS/DeepTutor · error · HTTPException

Knowledge base ' ' is connected to an external resource and…

Error message

Knowledge base '{resolved_name}' is connected to an external resource and has no local files.

What it means

Conflict response (409) from the internal raw-directory resolver (_resolve_kb_raw_dir): the target KB is an external-resource pointer (type obsidian, marginnote4, or linked) and intentionally has no DeepTutor-managed raw/ directory, so any endpoint that requires a local raw file cannot proceed. File listing treats this case as an empty collection for compatibility, but file-scoped endpoints surface it as an explicit conflict instead.

Solutions

  1. Read content through the matching external capability (Obsidian/MarginNote/linked-folder) instead of raw-file endpoints
  2. Perform raw-file operations only on KBs with locally uploaded documents
  3. Surface the 409 to the user as 'this KB is connected to an external resource and has no local files'
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at deeptutor/api/routers/knowledge.py:2310 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

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

    Connected KBs are external-resource pointers and intentionally have no
    DeepTutor-managed raw directory.  File listing treats that as an empty
    collection for backwards compatibility; endpoints that require a local
    file receive an explicit conflict response.
    """
    manager = _overridden_kb_manager()
    if manager is not None:
        resolved_name = _resolve_registered_kb_name(manager, kb_name)
    else:
        resource = resolve_kb(kb_name)
        manager = manager_for_resource(resource)
        resolved_name = resource.name

    kb_entry = _load_kb_entry_or_404(manager, resolved_name)
    if not supports_local_raw_files(kb_entry):
        if allow_unsupported:
            return None
        raise HTTPException(
            status_code=409,
            detail=(
                f"Knowledge base '{resolved_name}' is connected to an external resource "
                "and has no local files."
            ),
        )

    kb_path = manager.get_knowledge_base_path(resolved_name)
    return kb_path / "raw"


def _resolve_kb_raw_file_or_404(kb_name: str, filename: str) -> Path:
    """Resolve a raw KB file while preventing traversal outside raw/."""
    raw_dir = _resolve_kb_raw_dir(kb_name)
    assert raw_dir is not None  # allow_unsupported=False guarantees a path
    if not raw_dir.exists():
        raise HTTPException(status_code=404, detail="File not found")

View on GitHub (pinned to 3e82f13042)