HKUDS/DeepTutor · error · HTTPException

Spine not found

Error message

Spine not found

What it means

HTTP 404 raised by GET /books/{book_id}/spine in deeptutor/api/routers/book.py:497 when engine.load_spine(book_id) returns None — the book exists but has no compiled spine yet, meaning it has not finished (or undergone) the compilation stage that produces the structured table of contents.

Solutions

  1. Run the book compile step before requesting the spine
  2. Handle a null spine in the client by offering to compile
  3. Verify the book_id and its compilation state
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at deeptutor/api/routers/book.py:497 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/b28acf4528c1b85c. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/api/routers/book.py:497

    # A compiled book is hundreds of KB across one file per page.
    spine, pages, progress = await asyncio.to_thread(_read)
    return {
        "book": book.model_dump(mode="json"),
        "spine": spine.model_dump(mode="json") if spine else None,
        "pages": [
            (p.model_dump(mode="json") if include_blocks else _page_summary(p)) for p in pages
        ],
        "progress": progress.model_dump(mode="json"),
    }


@router.get("/books/{book_id}/spine")
async def get_spine(book_id: str) -> dict[str, Any]:
    engine = get_book_engine()
    spine = engine.load_spine(book_id)
    if spine is None:
        raise HTTPException(status_code=404, detail="Spine not found")
    return {"spine": spine.model_dump(mode="json")}


@router.get("/books/{book_id}/pages/{page_id}")
async def get_page(book_id: str, page_id: str) -> dict[str, Any]:
    engine = get_book_engine()
    page = engine.load_page(book_id, page_id)
    if page is None:
        raise HTTPException(status_code=404, detail="Page not found")
    return {"page": page.model_dump(mode="json")}


@router.delete("/books/{book_id}")
async def delete_book(book_id: str) -> dict[str, Any]:
    engine = get_book_engine()
    ok = engine.delete_book(book_id)
    if not ok:
        raise HTTPException(status_code=404, detail="Book not found")

View on GitHub (pinned to 3e82f13042)