A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix: report incomplete PDF annotation coverage
Amruth Pillaicc63819d3719
diff --git a/apps/web/src/features/resume/import/pdf-text.test.ts b/apps/web/src/features/resume/import/pdf-text.test.tsindex d1227db85..bd2c408f3 100644--- a/apps/web/src/features/resume/import/pdf-text.test.ts+++ b/apps/web/src/features/resume/import/pdf-text.test.ts@@ -68,15 +68,18 @@ it("refuses a partial PDF harvest before it can report a successful no-AI importawait expect(result).rejects.toThrow("Check that all pages have readable text, or try a smaller file.");});-it("preserves readable source as partial and refuses no-AI creation after a page text failure", async () => {- const raw = rawExtraction([[{ text: "Readable surviving page", x: 40, y: 60 }]]);- extract.mockResolvedValue({ ...raw, textReadFailed: true });- const file = new File(["%PDF-fixture"], "resume.pdf");- expect(await readPdfSource(file)).toMatchObject({ lines: ["Readable surviving page"], partial: true });- const reading = readResumeFile(file, "pdf", { aiAvailable: false });- await expect(reading).rejects.toThrow(ImportError);- await expect(reading).rejects.toThrow("Check that all pages have readable text, or try a smaller file.");-});+it.each(["textReadFailed", "annotationReadFailed"] as const)(+ "keeps incomplete source partial and refuses no-AI creation after %s",+ async (failure) => {+ const raw = rawExtraction([[{ text: "Readable surviving page", x: 40, y: 60 }]]);+ extract.mockResolvedValue({ ...raw, [failure]: true });+ const file = new File(["%PDF-fixture"], "resume.pdf");+ expect(await readPdfSource(file)).toMatchObject({ lines: ["Readable surviving page"], partial: true });+ const reading = readResumeFile(file, "pdf", { aiAvailable: false });+ await expect(reading).rejects.toThrow(ImportError);+ await expect(reading).rejects.toThrow("Check that all pages have readable text, or try a smaller file.");+ },+);describe("documentToLines", () => {it("groups items on the same baseline into one line", () => {diff --git a/apps/web/src/features/resume/import/pdf-text.ts b/apps/web/src/features/resume/import/pdf-text.tsindex cb3cdd9af..60fe31be7 100644--- a/apps/web/src/features/resume/import/pdf-text.ts+++ b/apps/web/src/features/resume/import/pdf-text.ts@@ -13,13 +13,13 @@ export async function readPdfSource(file: File) {return {lines: documentToLines(doc),links: (doc.links ?? []).flatMap((link) => (link.url ? [link.url] : [])),- partial: raw.truncated || raw.textReadFailed === true,+ partial: raw.truncated || raw.textReadFailed === true || raw.annotationReadFailed === true,};}export async function readPdfResume(file: File) {const raw = await extractPdf(file, { operatorBudgetMs: 0 });- if (raw.truncated || raw.textReadFailed)+ if (raw.truncated || raw.textReadFailed || raw.annotationReadFailed)throw new ImportError(t`Couldn't read the whole PDF. Check that all pages have readable text, or try a smaller file.`,);diff --git a/docs/guides/importing-resumes.mdx b/docs/guides/importing-resumes.mdxindex 6172fc18d..f3c9189c0 100644--- a/docs/guides/importing-resumes.mdx+++ b/docs/guides/importing-resumes.mdx@@ -50,7 +50,7 @@ A cover letter exported from Reactive Resume as JSON imports as a letter, not aWord files are read with their page headers and footers, where many templates keep the name and contact details. For PDFs, a profile such as LinkedIn gets its address from the link behind its name, and an empty email from a mail link. Mobile reads this source text on your server without another AI request.- If only part of the file could be compared, the review names that limit even when it lists leftover lines. This can happen with a long file or a page whose text couldn't be read. A scan, failed comparison or older server can leave no source text to compare after an AI reading; the review says so and asks you to check the file yourself. Reading a PDF without AI requires a server that supports previews and a complete readable text layer; update an older server or split a PDF longer than 30 pages before trying again. Nothing is saved until **Create resume**.+ If only part of the file could be compared, the review names that limit even when it lists leftover lines. This can happen with a long file, a page whose text couldn't be read, or link targets that couldn't be read. A scan, failed comparison or older server can leave no source text to compare after an AI reading; the review says so and asks you to check the file yourself. Reading a PDF without AI requires a server that supports previews and complete readable source text and links; update an older server or split a PDF longer than 30 pages before trying again. Nothing is saved until **Create resume**.<Frame caption="Web review of a fictional PDF, before creating the resume"><img src="/images/guides/importing-resumes/pdf-review.png" alt="Check what was found dialog for Avery-Morgan.pdf, listing two profile entries and one education entry, with Choose another file and Create resume controls" />@@ -139,7 +139,7 @@ Go through every section before you send the resume. PDF and Word files don't st/></Frame>-**"Couldn't read the whole PDF."** Check that every page has readable text; splitting a file won't repair an unreadable page. Text-layer import supports up to 30 pages, so split a longer PDF into smaller files and import each separately. A partial file is never imported as a complete resume.+**"Couldn't read the whole PDF."** Check that every page has readable text. If text or link targets cannot be read, try exporting a fresh copy; splitting a file won't repair unreadable content. Text-layer import supports up to 30 pages, so split a longer PDF into smaller files and import each separately. A partial file is never imported as a complete resume.**"This PDF is a scanned image."** Try the Word version of the resume, set up an AI provider, or start blank and paste your sections in.diff --git a/packages/api/src/features/resume/imports.test.ts b/packages/api/src/features/resume/imports.test.tsindex e6067456d..1bf50c0da 100644--- a/packages/api/src/features/resume/imports.test.ts+++ b/packages/api/src/features/resume/imports.test.ts@@ -60,27 +60,32 @@ it("reports bounded source coverage without parsing or importing a partial PDF",expect(create).not.toHaveBeenCalled();});-it("keeps surviving text partial and refuses creation after a page text read failed", async () => {- create.mockClear();- const bytes = readFileSync(new URL("./fixtures/import-review.pdf", import.meta.url));- const file = new File([bytes], "Fictional-damaged-resume.pdf");- const extraction = await import("./pdf-analysis");- const raw = await extraction.extractPdf(file, undefined, 0);- const read = vi.spyOn(extraction, "extractPdf").mockResolvedValue({ ...raw, textReadFailed: true });- try {- const context = { locale: "en-US" as const, reqHeaders: new Headers() };- const preview = await call(previewPdfImport, { file }, { context });- expect(preview.source.lines.join("\n")).toContain("Completed independent research on accessible interfaces.");- expect(preview.source.partial).toBe(true);- expect(preview.data).toBeNull();- await expect(call(importResumeFile, { file, format: "PDF" }, { context })).rejects.toMatchObject({- code: "BAD_REQUEST",- });- expect(create).not.toHaveBeenCalled();- } finally {- read.mockRestore();- }-});+it.each(["textReadFailed", "annotationReadFailed"] as const)(+ "keeps surviving source partial and refuses creation after %s",+ async (failure) => {+ create.mockClear();+ const bytes = readFileSync(new URL("./fixtures/import-review.pdf", import.meta.url));+ const file = new File([bytes], "Fictional-damaged-resume.pdf");+ const extraction = await import("./pdf-analysis");+ const raw = await extraction.extractPdf(file, undefined, 0);+ const read = vi+ .spyOn(extraction, "extractPdf")+ .mockResolvedValue({ ...raw, [failure]: true, links: failure === "annotationReadFailed" ? [] : raw.links });+ try {+ const context = { locale: "en-US" as const, reqHeaders: new Headers() };+ const preview = await call(previewPdfImport, { file }, { context });+ expect(preview.source.lines.join("\n")).toContain("Completed independent research on accessible interfaces.");+ expect(preview.source.partial).toBe(true);+ expect(preview.data).toBeNull();+ await expect(call(importResumeFile, { file, format: "PDF" }, { context })).rejects.toMatchObject({+ code: "BAD_REQUEST",+ });+ expect(create).not.toHaveBeenCalled();+ } finally {+ read.mockRestore();+ }+ },+);it.each([{diff --git a/packages/api/src/features/resume/imports.ts b/packages/api/src/features/resume/imports.tsindex 5614fb344..6cd171bc5 100644--- a/packages/api/src/features/resume/imports.ts+++ b/packages/api/src/features/resume/imports.ts@@ -13,7 +13,7 @@ async function readPdfImport(file: File, signal?: AbortSignal) {]);const raw = await extractPdf(file, signal, 0);const document = buildExtractedDocument(raw);- const partial = raw.truncated || raw.textReadFailed === true;+ const partial = raw.truncated || raw.textReadFailed === true || raw.annotationReadFailed === true;return {data: !partial && document.lines.length ? parsePdfResume(document) : null,source: {diff --git a/packages/resume/src/ats-pdf/harvest.test.ts b/packages/resume/src/ats-pdf/harvest.test.tsindex c9e9329cc..85edbbbe8 100644--- a/packages/resume/src/ats-pdf/harvest.test.ts+++ b/packages/resume/src/ats-pdf/harvest.test.ts@@ -91,6 +91,27 @@ describe("harvestPdfDocument", () => {expect(readable.textReadFailed).toBe(false);});+ it.each(["rejected", "malformed"])("keeps annotation coverage incomplete after a %s read", async (failure) => {+ const readable = makePage(1);+ readable.getAnnotations = vi.fn(async () => [+ { subtype: "Link", url: "https://example.org/fictional-profile", rect: [10, 20, 30, 40] },+ ]);+ const failed = makePage(2);+ failed.getAnnotations = vi.fn(async () => {+ if (failure === "rejected") throw new Error("Fictional annotation failure");+ return null;+ });+ const raw = await harvestPdfDocument(makeDocument([readable, failed]), { file: FILE });+ expect(raw.annotationReadFailed).toBe(true);+ expect(raw.textReadFailed).toBe(false);+ expect(raw.truncated).toBe(false);+ expect(raw.pages.map((page) => page.items.length)).toEqual([1, 1]);+ expect(raw.links).toHaveLength(1);+ expect(raw.links[0]?.url).toBe("https://example.org/fictional-profile");+ const complete = await harvestPdfDocument(makeDocument([readable, makePage(2)]), { file: FILE });+ expect(complete.annotationReadFailed).toBe(false);+ });+it("leaves operators null when the page blows its budget", async () => {const page = makePage(1, { operatorDelayMs: 50 });const raw = await harvestPdfDocument(makeDocument([page]), {diff --git a/packages/resume/src/ats-pdf/harvest.ts b/packages/resume/src/ats-pdf/harvest.tsindex e7d96c6ad..b5d774573 100644--- a/packages/resume/src/ats-pdf/harvest.ts+++ b/packages/resume/src/ats-pdf/harvest.ts@@ -281,6 +281,7 @@ export async function harvestPdfDocument(document: PdfDocumentLike, options: Harlet operatorsAttempted = false;let operatorsSucceeded = false;let textReadFailed = false;+ let annotationReadFailed = false;for (let pageNumber = 1; pageNumber <= harvestedPageCount; pageNumber += 1) {throwIfAborted();@@ -296,6 +297,7 @@ export async function harvestPdfDocument(document: PdfDocumentLike, options: Harconst rawItems = (textContent as PdfTextContentLike | null)?.items;if (!Array.isArray(rawItems)) textReadFailed = true;+ if (!Array.isArray(annotations)) annotationReadFailed = true;const items: RawTextItem[] = [];if (Array.isArray(rawItems)) {@@ -354,6 +356,7 @@ export async function harvestPdfDocument(document: PdfDocumentLike, options: HarpageCount,truncated: pageCount > harvestedPageCount,textReadFailed,+ annotationReadFailed,pages,fonts: [...fonts.values()],links,diff --git a/packages/resume/src/ats-pdf/types.ts b/packages/resume/src/ats-pdf/types.tsindex e2a014e67..a1355d597 100644--- a/packages/resume/src/ats-pdf/types.ts+++ b/packages/resume/src/ats-pdf/types.ts@@ -90,6 +90,8 @@ export type RawExtraction = {truncated: boolean;/** A page's text could not be read; absent in older extraction receipts. */textReadFailed?: boolean;+ /** A page's links could not be read; absent in older extraction receipts. */+ annotationReadFailed?: boolean;pages: readonly RawPage[];fonts: readonly RawFont[];links: readonly RawLinkAnnotation[];