{"record":{"id":"8e7d9fbae30629f8","repo":"santifer/career-ops","slug":"message-strict-pages-requested","errorCode":null,"errorMessage":"${message} (--strict-pages requested)","messagePattern":"(.+?) \\(--strict-pages requested\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"generate-pdf.mjs","lineNumber":872,"sourceCode":" * @returns {void}\n */\nexport function enforcePageBudget(pageCount, { maxPages = 2, strictPages = false } = {}) {\n  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;","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/santifer/career-ops/blob/60398d6549a46f5266929538af21cfab94badc75/generate-pdf.mjs#L854-L890","documentation":"The strict variant of the page-budget failure: the rendered PDF has more pages than maxPages and --strict-pages was requested, so enforcePageBudget() throws instead of warning. The message states the actual and allowed page counts and names the recommended trim targets: lower-priority bullets, older roles, secondary projects, the competencies strip. Without --strict-pages the same condition is only a console warning.","triggerScenarios":"cv.md grew past the budget (long career history) while profile.yml has max_pages: 1; CI gates that render with --strict-pages to enforce one-page CVs; a batch of tailored CVs where one variant added too many bullets.","commonSituations":"Senior candidates with many roles squeezing into max_pages: 1; strict quality gates in automated application pipelines; adding competencies/projects without removing equivalent content.","solutions":["Trim content per the message's priority list: lower-priority bullets first, then older roles, secondary projects, and the competencies strip; regenerate.","If the market/role genuinely warrants it, raise max_pages in config/profile.yml (e.g. 2 for senior CVs).","If the extra page is acceptable for this one render, drop --strict-pages to downgrade the failure to a warning — a conscious choice, not a fix."],"exampleFix":"# before\nnode generate-pdf.mjs --strict-pages   # cv.md is 3 pages, max_pages: 2 -> throws\n\n# after (option A: trim cv.md bullets/roles; option B:)\n# config/profile.yml\nmax_pages: 3","handlingStrategy":"fallback","validationCode":"// before a strict CI render, check the budget path is plausible:\n// keep cv.md lean and assert bullet counts per role in a lint step\nfunction cvBulletCount(cv) { return (cv.match(/^\\s*- /gm) || []).length; }\nif (cvBulletCount(cvMarkdown) > 45 && maxPages === 1) {\n  console.warn('cv.md is likely over 1 page — trim before the strict render');\n}","typeGuard":null,"tryCatchPattern":"try {\n  enforcePageBudget(pageCount, { maxPages, strictPages: true });\n} catch (err) {\n  if (err.message.includes('(--strict-pages requested)')) {\n    // message names the trim targets: lower-priority bullets, older roles, secondary projects, competencies strip\n    failBuildWithGuidance(err.message);\n  } else throw err;\n}","preventionTips":["Set max_pages honestly for your seniority level: 1 for juniors, 2 for senior CVs.","Whenever you add bullets to cv.md, remove comparable content — net page growth should be a conscious decision.","Keep --strict-pages in CI so over-length CVs block the pipeline instead of shipping quietly."],"tags":["pdf","page-budget","cv","strict-mode"],"backgroundTag":"page-budget-exceeded","analyzedSha":"60398d6549a46f5266929538af21cfab94badc75","analyzedAt":"2026-08-20T23:00:06.764Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}