santifer/career-ops · warning · Error

CV section order diverges from cv.md: rendered ${renderedOrd

Error message

CV section order diverges from cv.md: rendered ${renderedOrder}; cv.md ${sourceOrder}

What it means

validateCvSectionOrder compares the section heading order in the rendered CV HTML against the order in cv.md. If the rendered order reverses the source order (a section appears before another that precedes it in cv.md), the validation throws — unless allowReorder (--allow-reorder) downgrades it to a console warning. This catches accidental reordering by an agent or a template that scrambles sections.

Source

Thrown at generate-pdf.mjs:269

  const sourcePositions = new Map(source.map((section, index) => [section.key, index]));
  const renderedComparable = rendered.filter(section => sourcePositions.has(section.key));
  if (renderedComparable.length < 2) return;

  for (let i = 1; i < renderedComparable.length; i++) {
    const previous = renderedComparable[i - 1];
    const current = renderedComparable[i];
    if (sourcePositions.get(current.key) < sourcePositions.get(previous.key)) {
      const renderedOrder = renderedComparable.map(section => section.title).join(' -> ');
      const sourceOrder = source
        .filter(section => renderedComparable.some(renderedSection => renderedSection.key === section.key))
        .map(section => section.title)
        .join(' -> ');
      const message = `CV section order diverges from cv.md: rendered ${renderedOrder}; cv.md ${sourceOrder}`;
      if (allowReorder) {
        console.warn(`⚠️  ${message} (proceeding — --allow-reorder set)`);
        return;
      }
      throw new Error(message);
    }
  }
}

/**
 * Decide whether a rendered CV fits its configured page budget.
 *
 * This is deliberately separate from rendering: page count comes from the
 * PDF Chromium actually produced, and the renderer never changes layout to
 * force content under the limit.
 *
 * @param {number} pageCount - Actual pages in the rendered PDF.
 * @param {{ maxPages?: number, strictPages?: boolean }} [options]
 * @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}).`);

View on GitHub (pinned to 9b17a8ac97)

Solutions

  1. If the reorder is intentional, pass --allow-reorder to downgrade the error to a warning.
  2. If unintentional, fix the HTML template or the agent's section ordering to match cv.md.
  3. Reorder cv.md itself if the source order is what you want the rendered order to be.

Example fix

# before
node generate-pdf.mjs
# throws: CV section order diverges from cv.md

# after — intentional reorder
node generate-pdf.mjs --allow-reorder
Defensive patterns

Strategy: validation

Validate before calling

// Validate before render if you have both html and cvMarkdown
import { validateCvSectionOrder } from './generate-pdf.mjs';

try {
  validateCvSectionOrder(html, cvMarkdown, { allowReorder: intentionalReorder });
} catch (err) {
  console.warn('Section order divergence detected:', err.message);
  if (!intentionalReorder) throw err;
}

Try / catch

try {
  validateCvSectionOrder(html, cvMarkdown);
} catch (err) {
  if (err.message.includes('section order diverges') && intentionalReorder) {
    // Re-run with allowReorder instead
    validateCvSectionOrder(html, cvMarkdown, { allowReorder: true });
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: An agent tailored the CV and moved Projects ahead of Experience; a custom HTML template has a fixed section order that differs from cv.md; cv.md sections were reordered but the HTML was not regenerated from the new source; the template injects a section (e.g. a sidebar) that shifts the perceived order.

Common situations: Tailoring a CV for a technical role moves Projects up intentionally; a template reorder is accidental (agent hallucination); the rendered extraction picks up non-content headings.

Related errors


AI-assisted analysis of santifer/career-ops@9b17a8ac97 (2026-08-13). Data as JSON: /api/errors/3d505bacb47d77d2. Report an issue: GitHub.