fix: return CSV output when a PDF isn't split

Merged
CY
1mo ago
+85-4

What

partition with CSV output now returns the CSV whenever the PDF isn't actually split.

partition({ files: report.txt, splitPdfPage: true }, { acceptHeaderOverride: "text/csv" })

Before: SyntaxError: Unexpected token 'y', "type,text..." is not valid JSON
After:  "type,text\nTitle,Hello\n"

Why

The split-PDF hook ran on every response and tried to merge it as JSON, even when no split happened: splitting off, a non-PDF file, or a PDF too small to split. A CSV body can't be read as JSON, so the call failed. The hook now passes the response through untouched when there was no split. Real splits behave as before.

Validation

Tests call the public client for CSV with splitting off, a non-PDF file, and a one-page PDF, plus JSON output and two operations running at once. All 35 unit tests pass.