santifer/career-ops · warning

⚠️ ${message} Continuing because overflow is warning-only b

Error message

⚠️  ${message} Continuing because overflow is warning-only by default; use --strict-pages to reject it.

What it means

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.

Source

Thrown at generate-pdf.mjs:875

  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;

  for (const match of pdf.matchAll(objectPattern)) {
    const streamIndex = match[3].search(/\bstream(?:\r?\n|\r)/);

View on GitHub (pinned to 60398d6549)

Solutions

  1. Trim lower-priority bullets, older roles, secondary projects, or the competencies strip as the message suggests, then regenerate
  2. Raise or remove the max-pages limit in the generation options if the extra page is acceptable
  3. Add --strict-pages in CI or scripted runs so overflow fails the build instead of shipping silently

Example fix

# before
node generate-pdf.mjs cv.html --max-pages 1  # warns, still writes 2-page PDF

# after — either trim cv.md content, or:
node generate-pdf.mjs cv.html --max-pages 1 --strict-pages  # rejects overflow
Defensive patterns

Strategy: validation

Validate before calling

// After rendering, read the true page count from the PDF catalog (same method
// as the tool) and reject overflow yourself:
import { countRenderedPdfPages } from './generate-pdf.mjs'; // if exported
// or parse /Count in the root /Pages dict:
function pdfPageCount(buf) {
  const m = buf.toString('latin1').match(/\/Type\s*\/Pages[^]*?\/Count\s+(\d+)/);
  return m ? Number(m[1]) : 0;
}
if (pdfPageCount(pdfBuf) > maxPages) throw new Error('page budget exceeded');

Try / catch

// With --strict-pages the same condition throws:
try {
  await generatePdf({ strictPages: true });
} catch (err) {
  if (err instanceof Error && err.message.includes('the allowed maximum is')) {
    // trim content or raise maxPages, then regenerate
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of santifer/career-ops@60398d6549 (2026-08-20). Data as JSON: /api/errors/5c92c0623ed86754. Report an issue: GitHub.