HKUDS/DeepTutor · error · ValueError
Page references unknown chapter
Error message
Page {page_id} references unknown chapter {page.chapter_id} What it means
Referential-integrity guard during page compilation: the page row exists but its chapter_id does not match any chapter in the loaded spine (stale spine or orphaned page), so the compiler cannot place the page.
Solutions
- Re-confirm/rebuild the spine so page chapter_ids match current chapters
- Drop and recreate the page shell if its chapter was removed intentionally
- Rebuild the whole book to re-derive consistent page/chapter links
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/book/engine.py:1106 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/edf33e32517f7f88.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/book/engine.py:1106
# their hand-built blocks — that would overwrite the deterministic
# "How to read this book" intro and chapter index with hallucinated
# prose. Reaching here means force=True or the page is not yet READY, so
# rebuild deterministically (this also refreshes a changed spine).
if page.content_type == ContentType.OVERVIEW:
page.status = PageStatus.PENDING
self.storage.save_page(page)
await self._materialize_overview_page(spine, [page], book, stream=stream)
page = self.storage.load_page(book_id, page_id) or page
await self._maybe_finalize_book(book_id)
return page
if force:
self._reset_page_for_force_compile(page)
self.storage.save_page(page)
chapter = spine.chapter_by_id(page.chapter_id)
if chapter is None:
raise ValueError(f"Page {page_id} references unknown chapter {page.chapter_id}")
bus = stream or get_book_bus(book_id)
bstream = BookStream(bus)
try:
async with bstream.stage(STAGE_COMPILATION):
page = await self.compiler.compile_page(
book_id=book_id,
chapter=chapter,
page=page,
stream=bstream,
knowledge_bases=book.knowledge_bases,
language=book.language,
depth=book.depth.value,
)
except Exception as exc:
self._mark_page_error(page, exc, prefix="Compilation failed")
raiseView on GitHub (pinned to 3e82f13042)