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
- If the reorder is intentional, pass --allow-reorder to downgrade the error to a warning.
- If unintentional, fix the HTML template or the agent's section ordering to match cv.md.
- 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
- If section reordering is intentional for a role, pass --allow-reorder.
- Keep cv.md and the HTML template in sync — edit one, regenerate the other.
- After agent edits to a tailored CV, validate section order before generating the PDF.
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
- payload.cv requires { section, entry }
- payload.cv requires a non-empty dedupKey (used for dedup/ide
- Unresolved placeholders: ${[...unresolved].join(', ')}
- Could not determine the rendered PDF page count (received ${
- Invalid page budget "${maxPages}". Use a positive integer.
AI-assisted analysis of santifer/career-ops@9b17a8ac97 (2026-08-13).
Data as JSON: /api/errors/3d505bacb47d77d2.
Report an issue: GitHub.