{"record":{"id":"5c92c0623ed86754","repo":"santifer/career-ops","slug":"message-continuing-because-overflow-is-warn","errorCode":null,"errorMessage":"⚠️  ${message} Continuing because overflow is warning-only by default; use --strict-pages to reject it.","messagePattern":"⚠️  (.+?) Continuing because overflow is warning-only by default; use --strict-pages to reject it\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"generate-pdf.mjs","lineNumber":875,"sourceCode":"  if (!Number.isInteger(pageCount) || pageCount < 1) {\n    throw new Error(`Could not determine the rendered PDF page count (received ${pageCount}).`);\n  }\n  if (!Number.isInteger(maxPages) || maxPages < 1) {\n    throw new Error(`Invalid page budget \"${maxPages}\". Use a positive integer.`);\n  }\n  if (pageCount <= maxPages) return;\n\n  const actualLabel = 'pages';\n  const allowedLabel = maxPages === 1 ? 'page' : 'pages';\n  const message =\n    `CV is ${pageCount} ${actualLabel}; the allowed maximum is ${maxPages} ${allowedLabel}. ` +\n    'Trim lower-priority bullets, older roles, secondary projects, or the competencies strip, then regenerate.';\n\n  if (strictPages) {\n    throw new Error(`${message} (--strict-pages requested)`);\n  }\n\n  console.warn(`⚠️  ${message} Continuing because overflow is warning-only by default; use --strict-pages to reject it.`);\n}\n\n/**\n * Read the page count from the PDF catalog's root /Pages dictionary.\n *\n * Following the catalog reference keeps page-like text in content streams or\n * metadata from being mistaken for an actual page object.\n *\n * @param {Buffer} pdfBuffer - PDF bytes returned by Chromium.\n * @returns {number}\n */\nfunction countRenderedPdfPages(pdfBuffer) {\n  const pdf = pdfBuffer.toString('latin1');\n  const objects = new Map();\n  const objectPattern = /(?:^|[\\r\\n])(\\d+)\\s+(\\d+)\\s+obj\\b([\\s\\S]*?)\\bendobj\\b/g;\n\n  for (const match of pdf.matchAll(objectPattern)) {\n    const streamIndex = match[3].search(/\\bstream(?:\\r?\\n|\\r)/);","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/santifer/career-ops/blob/60398d6549a46f5266929538af21cfab94badc75/generate-pdf.mjs#L857-L893","documentation":"Post-render page-count check in generate-pdf.mjs: it reads the real page count from the PDF catalog's /Pages dictionary and compares it to the configured maximum. Overflow normally only warns (with trimming advice); with --strict-pages the same condition throws an Error and rejects the output.","triggerScenarios":"Generating a PDF whose rendered page count exceeds maxPages (e.g. 2 pages against a 1-page limit) — countRenderedPdfPages returns pageCount > maxPages and, without --strict-pages, the warning is printed and the file is still produced.","commonSituations":"CV grew after adding roles or bullets; max-pages lowered to fit a recruiter's 1-page requirement; content-heavy competencies strip pushing text onto an extra page.","solutions":["Trim lower-priority bullets, older roles, secondary projects, or the competencies strip as the message suggests, then regenerate","Raise or remove the max-pages limit in the generation options if the extra page is acceptable","Add --strict-pages in CI or scripted runs so overflow fails the build instead of shipping silently"],"exampleFix":"# before\nnode generate-pdf.mjs cv.html --max-pages 1  # warns, still writes 2-page PDF\n\n# after — either trim cv.md content, or:\nnode generate-pdf.mjs cv.html --max-pages 1 --strict-pages  # rejects overflow","handlingStrategy":"validation","validationCode":"// After rendering, read the true page count from the PDF catalog (same method\n// as the tool) and reject overflow yourself:\nimport { countRenderedPdfPages } from './generate-pdf.mjs'; // if exported\n// or parse /Count in the root /Pages dict:\nfunction pdfPageCount(buf) {\n  const m = buf.toString('latin1').match(/\\/Type\\s*\\/Pages[^]*?\\/Count\\s+(\\d+)/);\n  return m ? Number(m[1]) : 0;\n}\nif (pdfPageCount(pdfBuf) > maxPages) throw new Error('page budget exceeded');","typeGuard":null,"tryCatchPattern":"// With --strict-pages the same condition throws:\ntry {\n  await generatePdf({ strictPages: true });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('the allowed maximum is')) {\n    // trim content or raise maxPages, then regenerate\n  } else throw err;\n}","preventionTips":["Use --strict-pages in any scripted/CI generation so overflow fails instead of warning","Re-check page count after every cv.md content addition, especially the competencies strip"],"tags":["pdf","page-limit","cv-generation","cli","warning"],"backgroundTag":"page-limit-exceeded","analyzedSha":"60398d6549a46f5266929538af21cfab94badc75","analyzedAt":"2026-08-20T23:00:06.764Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}