santifer/career-ops · error · Error
(--strict-pages requested)
Error message
${message} (--strict-pages requested) What it means
When the rendered CV exceeds the page budget and the strictPages option is set, enforcePageBudget throws this error (the budget message plus a '(--strict-pages requested)' suffix). By default overflow is only a console warning; --strict-pages turns it into a hard failure, e.g. for CI gates that must reject an over-long CV.
Solutions
- Trim the CV content as the message suggests: cut lower-priority bullets, older roles, secondary projects, or the competencies strip, then regenerate
- Raise the budget with a larger --max-pages value if 2 pages is not actually a requirement
- Remove --strict-pages if overflow should only warn (default behavior)
- Check the rendered output for accidental layout bloat (huge images/margins) inflating the page count
Example fix
# before (fails) $ node generate-pdf.mjs --in cv.html --out cv.pdf --strict-pages Error: CV is 3 pages; the allowed maximum is 2 pages. ... (--strict-pages requested) # after: trim content, or relax the gate $ node generate-pdf.mjs --in cv.html --out cv.pdf --max-pages=3 --strict-pages
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: render once, count pages, decide before enforcing strictly
const pageCount = countRenderedPdfPages(pdfBuffer);
if (pageCount > maxPages && strictPages) {
console.warn(`CV will fail --strict-pages: ${pageCount} pages > ${maxPages}`);
} Type guard
const fitsBudget = (pageCount, maxPages) => Number.isInteger(pageCount) && pageCount >= 1 && pageCount <= maxPages;
Try / catch
try {
enforcePageBudget(pageCount, { maxPages, strictPages: true });
} catch (err) {
if (err.message.includes('--strict-pages requested')) {
console.error('CV exceeds page budget:', err.message);
process.exit(1); // CI gate: fail the build with the actionable message
}
throw err;
} Prevention
- Run --strict-pages in CI to catch CV overflow before sending it out
- Trim older roles/bullets whenever the warning (non-strict run) appears
- Set an explicit --max-pages matching your real requirement instead of relying on the default of 2
- Re-check the page count after every CV content edit
When it happens
Trigger: Running the PDF generation with --strict-pages (or calling enforcePageBudget with strictPages: true) on a CV whose actual rendered page count exceeds maxPages — e.g. a 3-page CV with the default 2-page budget.
Common situations: CI pipelines enforcing a 2-page CV limit fail after a candidate adds roles/bullets; batch renders where one tailored variant overflows; users surprised that plain runs only warn but their scripted --strict-pages run fails.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Application Answers section has
- Could not determine the rendered PDF page count
- --from and --to must both be supplied together (or neither…
- --from ( ) must not be after --to ( ).
- Invalid page budget " ". Use a positive integer.
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/8e7d9fbae30629f8.
Report an issue: GitHub.
Appendix: source
Thrown at generate-pdf.mjs:1035
* @returns {void}
*/
export function enforcePageBudget(pageCount, { maxPages = 2, strictPages = false } = {}) {
if (!Number.isInteger(pageCount) || pageCount < 1) {
throw new Error(`Could not determine the rendered PDF page count (received ${pageCount}).`);
}
if (!Number.isInteger(maxPages) || maxPages < 1) {
throw new Error(`Invalid page budget "${maxPages}". Use a positive integer.`);
}
if (pageCount <= maxPages) return;
const actualLabel = 'pages';
const allowedLabel = maxPages === 1 ? 'page' : 'pages';
const message =
`CV is ${pageCount} ${actualLabel}; the allowed maximum is ${maxPages} ${allowedLabel}. ` +
'Trim lower-priority bullets, older roles, secondary projects, or the competencies strip, then regenerate.';
if (strictPages) {
throw new Error(`${message} (--strict-pages requested)`);
}
console.warn(`⚠️ ${message} Continuing because overflow is warning-only by default; use --strict-pages to reject it.`);
}
/**
* Read the page count from the PDF catalog's root /Pages dictionary.
*
* Following the catalog reference keeps page-like text in content streams or
* metadata from being mistaken for an actual page object.
*
* @param {Buffer} pdfBuffer - PDF bytes returned by Chromium.
* @returns {number}
*/
function countRenderedPdfPages(pdfBuffer) {
const pdf = pdfBuffer.toString('latin1');
const objects = new Map();
const objectPattern = /(?:^|[\r\n])(\d+)\s+(\d+)\s+obj\b([\s\S]*?)\bendobj\b/g;View on GitHub (pinned to aac998c7ed)