Skip to content

fix(ingestor): ParseError(ValueError) escapes as HTTP 500 for encrypted/oversized PDFs #282

Closed

Description

@piyushmakhija28

Summary

ParseError(ValueError) raised by PyMuPDFParser.parse() for encrypted or oversized PDFs is caught at ingestor.py:214 by except (AssertionError, ValueError, TypeError): raise, which re-raises it bare. FastAPI has no handler for raw ValueError, so callers receive HTTP 500.

Root cause

Fix #242/#246 added class ParseError(ValueError) in parser.py. But PipelineIngestor at line 214 has except (AssertionError, ValueError, TypeError): raise which catches ParseError (since it IS a ValueError) and re-raises before it can be mapped to a user-friendly error.

Fix

backend/app/adapters/ingestor.py -- catch ParseError before the generic ValueError catch and map it to a 422:

  • from ingestion.parser import ParseError
  • except ParseError as exc: raise validation_error(str(exc)) from exc
  • (then the existing ValueError block re-raises)

Impact

Users uploading encrypted PDFs or files >100 MB receive HTTP 500 instead of 422.

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