Skip to content

fix: fall back when mutool fails instead of returning empty HTML - #272

Merged
Kikobeats merged 3 commits into
masterfrom
cursor/critical-bug-management-3936
Aug 7, 2026
Merged

fix: fall back when mutool fails instead of returning empty HTML#272
Kikobeats merged 3 commits into
masterfrom
cursor/critical-bug-management-3936

Conversation

@cursor

@cursor cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

When mutool throws after a successful PDF fetch, getHTML returned html: '' with no statusCode/headers — a blank “success” shell. Same failure class as the pandoc empty/error path fixed in #265.

Root cause

The PDF/mutool branch in src/index.js had no try/catch. A conversion throw escaped into fetch’s outer catch, which intentionally returns an empty body for network failures.

Fix

Catch mutool failures (and empty conversion output), log mutool:error / mutool:empty, and fall through to the raw-body path so the successful HTTP response is preserved.

Validation

  • Added falls back when mutool throws after a successful fetch (local PDF fixture + rejecting mutool → statusCode: 200, non-empty html).
  • npx ava test/pdf.js -m 'falls back when mutool throws*' passed.
Open in Web View Automation 

cursoragent and others added 2 commits August 7, 2026 04:21
PDF conversion had no try/catch (unlike pandoc after #265). A mutool
throw after a successful fetch escaped into fetch's outer catch, which
returned html:'' with no statusCode/headers — a blank success shell.

Catch mutool failures (and empty output), log them, and fall through to
the raw body path so the successful response is preserved.

Co-authored-by: kikohumanbeatbox <kikohumanbeatbox@gmail.com>
The fallback path decoded the entire PDF buffer through toEncode, but
addBody drops non-media, non-JSON bodies, so the result was discarded.
A 20MB PDF with a failing mutool spent 7.5s producing a 190-char document.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017693rzpJsPgMSn8xPq3pz2
@Kikobeats
Kikobeats marked this pull request as ready for review August 7, 2026 07:43
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017693rzpJsPgMSn8xPq3pz2
@Kikobeats
Kikobeats merged commit 32202ad into master Aug 7, 2026
2 checks passed
@Kikobeats
Kikobeats deleted the cursor/critical-bug-management-3936 branch August 7, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants