Skip to content

fix(workspaces): resolve text-less PDFs to an empty projection#667

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/textless-pdf-empty-projection
Draft

fix(workspaces): resolve text-less PDFs to an empty projection#667
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/textless-pdf-empty-projection

Conversation

@posthog

@posthog posthog Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Uploading a scanned or image-only PDF (one with no text layer) failed hard with "Extraction did not produce usable page Markdown." instead of finishing gracefully. LiteParse trims each page's Markdown, so whitespace-only pages collapse to empty strings, tripping the usablePageCount === 0 guard and rejecting the whole extraction.

This change distinguishes two cases:

  • No pages at all from the provider → still a genuine failure (now "Extraction did not produce any pages.").
  • Pages exist but all are empty → a valid outcome for text-less PDFs. It now resolves into a valid projection with blank pages and a hasExtractableText: false marker on the manifest and file-projection metadata, so the file is marked done-with-no-text rather than failed.

Why

Users uploading text-less/scanned PDFs hit a hard extraction failure instead of a graceful "no extractable text" result — a small but real UX gap on the PDF extraction path.

Testing

  • pnpm check (format + lint + types) — pass
  • pnpm test src/features/workspaces/extraction — 19 tests pass, including new cases for all-empty pages resolving to an empty projection and page-less extractions still being rejected.

Created with PostHog Code from this inbox report.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Review in cubic

Extraction previously threw "Extraction did not produce usable page
Markdown." whenever every page came back empty, which happens naturally
for scanned or image-only PDFs with no text layer (LiteParse trims each
page's Markdown, so whitespace-only pages collapse to empty strings).

Distinguish "the provider gave us no pages at all" (still a genuine
failure) from "the PDF has pages but no extractable text" (a valid
outcome). The latter now resolves into a valid projection with blank
pages and a `hasExtractableText: false` marker recorded on the manifest
and file projection metadata, so the file is marked done-with-no-text
instead of failed.

Generated-By: PostHog Code
Task-Id: 97353e21-4b24-4afc-9a1f-2846a17dda22
@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit a5f656c.

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

0 participants