Skip to content

fix(parser): page_count uses fitz total but pages tuple is shorter after per-page skip -- section page_end out of range #288

Closed

Description

@piyushmakhija28

Summary

Fix #275 added per-page try/except so corrupt pages are skipped with a warning. But ParsedDocument is constructed with page_count=doc.page_count (total fitz page count including skipped pages) while pages=tuple(pages_list) only contains successfully parsed pages. Downstream code (toc_extractor._derive_page_ranges) uses page_count as the ceiling for the last section's page_end, creating section ranges that reference page numbers with no corresponding Page object in doc.pages. This causes silent gaps in chunking where chunks are expected but never created.

Fix

ingestion/parser.py after the per-page loop: set page_count=len(pages_list) so it matches the actual number of parsed pages.

Impact

Documents with corrupt/skipped pages have incorrect TOC section page ranges. Chunks expected for those sections are never created, producing silent content gaps.

Activity

  1. added
    bugSomething isn't working
    priority: highData loss, security, or major correctness bug
    code-reviewFound via automated code review
    on Jun 21, 2026
  2. piyushmakhija28 commented on Jun 21, 2026

    @piyushmakhija28
    ContributorAuthor

    Fixed in PR #280 (Sprint R3/R4: fix(sprint-r3): root-cause fixes for all 39 bugs from code review round 3 + Sprint R4 round 4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcode-reviewFound via automated code reviewpriority: highData loss, security, or major correctness bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions