HKUDS/DeepTutor · error · HTTPException

Book not found

Error message

Book not found

What it means

HTTP 404 raised throughout deeptutor/api/routers/book.py (e.g. _derive_capture_title_values and the /books/{book_id} handlers) when engine.load_book(book_id) returns None. The book_id in the path does not correspond to any compiled book, so the request cannot proceed.

Solutions

  1. Verify the book_id used by the client matches an existing book
  2. List available books before deep-linking
  3. Handle 404 by removing stale book references from the UI
Defensive patterns

Strategy: type-guard

When it happens

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

Appendix: source

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

        LearningCaptureStatus.IMPORTED,
    },
    LearningCaptureStatus.IMPORTED: {LearningCaptureStatus.IMPORTED},
    LearningCaptureStatus.REJECTED: {LearningCaptureStatus.REJECTED},
}


def _is_capture_transition_allowed(
    current: LearningCaptureStatus,
    requested: LearningCaptureStatus,
) -> bool:
    return requested in _CAPTURE_TRANSITIONS.get(current, set())


def _derive_capture_title_values(book_id: str, page_id: str, block_id: str) -> tuple[str, str, str]:
    engine = get_book_engine()
    book = engine.load_book(book_id)
    if book is None:
        raise HTTPException(status_code=404, detail="Book not found")
    page = engine.load_page(book_id, page_id)
    if page is None:
        raise HTTPException(status_code=404, detail="Page not found")

    spine = engine.load_spine(book_id)
    chapter_title = page.title
    if spine is not None and page.chapter_id:
        for chapter in spine.chapters:
            if chapter.id == page.chapter_id:
                chapter_title = chapter.title
                break

    base_locator = f"/book/{book_id}/pages/{page_id}"
    source_locator = f"{base_locator}/block/{block_id}" if block_id else base_locator
    return book.title, chapter_title, source_locator


def _find_capture_duplicate(

View on GitHub (pinned to 3e82f13042)