HKUDS/DeepTutor · error · HTTPException

entry not found in any L2 doc

Error message

entry not found in any L2 doc

What it means

Result of resolve_entry's scan: the entry_id is well-formed but no L2 surface markdown document contains it — typically because the entry was deleted by a consolidation run or the citing L3 doc holds a stale reference.

Solutions

  1. Reload or re-open the L3 doc so it re-cites current L2 entry ids
  2. If the entry was removed by consolidation, treat the footnote as dead and drop it in the UI
  3. Run a merge/dedup pass and re-resolve afterwards
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at deeptutor/api/routers/memory.py:121 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/1a553094ee6e0221. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/api/routers/memory.py:121

    Scans the seven L2 mds in order; first hit wins. 404 if no L2 doc
    contains the id (e.g. the entry was deleted or the id is stale).
    """
    if not _ENTRY_ID_RE.match(entry_id):
        raise HTTPException(status_code=400, detail="not a valid entry id")
    from deeptutor.services.memory.document import parse

    for surface in SURFACES:
        path = paths.l2_file(surface)
        if not path.exists():
            continue
        try:
            doc = parse(path.read_text(encoding="utf-8"))
        except Exception:  # noqa: BLE001 — malformed L2 should not 500 the resolver
            continue
        for entry in doc.all_entries():
            if entry.id == entry_id:
                return {"layer": "L2", "key": surface, "entry_id": entry_id}
    raise HTTPException(status_code=404, detail="entry not found in any L2 doc")


@router.get("/backup")
async def list_backups():
    backup_dir = paths.backup_root()
    if not backup_dir.exists():
        return {"backups": []}
    out: list[dict] = []
    for entry in sorted(backup_dir.iterdir()):
        if entry.is_dir():
            files = sorted(p.name for p in entry.iterdir())
            out.append({"name": entry.name, "files": files})
    return {"backups": out}


# ── Doc read / write / delete ────────────────────────────────────────────

View on GitHub (pinned to 3e82f13042)