API returns 500 when document has zero-byte pages

Found a bug: if you submit a PDF that contains a zero-byte page (corrupted PDF, essentially), the API returns a 500 internal server error instead of a meaningful error message.

Expected: 400 with a message like “Invalid PDF: page 3 contains no data”
Actual: 500 with generic “Internal Server Error”

curl -X POST https://api.qomplement.com/v1/parse \
  -H "Authorization: Bearer $API_KEY" \
  -F "file=@corrupted_doc.pdf" \
  -F "template_id=inv_standard"
# Returns: {"error": "Internal Server Error", "status": 500}

Reproducible 100% of the time with the attached test PDF. Happy to share the file if helpful.

1 Like

Thanks for the detailed report Dev! This is a known issue we’re fixing. The parser should gracefully skip corrupted pages and return results for the valid ones, plus a warning. Fix should be out next week.

3 Likes

Great, thanks Daniel. For now I’m adding a PDF validation step before submitting to the API which catches most of these.

2 Likes