santifer/career-ops · error · Error

invalid format " " (use: )

Error message

invalid format "${entryFormat}" (use: ${validFormats.join(', ')})

What it means

Each batch manifest entry's paper format — the entry's own format field, falling back to the batch-global format — must be one of the valid formats ('a4', 'letter', compared case-insensitively). Any other value fails that entry with this error listing the accepted formats, because Chromium's page.pdf only supports those paper formats.

Solutions

  1. Change the entry's format (or the global format) to "a4" or "letter"
  2. Check for hidden whitespace/BOM in the manifest value — retype the value as plain a4 or letter
  3. Remove the per-entry format key entirely to inherit the valid global default
  4. If you need another paper size, this tool does not support it — pre-render with your own Playwright page.pdf call using the desired format

Example fix

// before
{"input": "cv.html", "output": "cv.pdf", "format": "legal"}
// after
{"input": "cv.html", "output": "cv.pdf", "format": "letter"}
Defensive patterns

Strategy: validation

Validate before calling

const VALID_FORMATS = ['a4', 'letter'];
const fmt = String(spec.format ?? globalFormat ?? 'a4').toLowerCase().trim();
if (!VALID_FORMATS.includes(fmt)) throw new Error(`invalid format "${fmt}" (use: ${VALID_FORMATS.join(', ')})`);

Type guard

const isValidFormat = (f) => typeof f === 'string' && ['a4', 'letter'].includes(f.toLowerCase().trim());

Try / catch

try {
  await renderBatch(manifestPath);
} catch (err) {
  if (err.message.startsWith('invalid format')) {
    console.error(err.message, '— fix the entry/global format field');
    process.exit(1);
  }
  throw err;
}

Prevention

When it happens

Trigger: A manifest entry or the global batch format set to something like "A3", "legal", "A4 " (with whitespace is fine — it's lowercased but not trimmed — actually "a4 ".toLowerCase() is 'a4 ' which fails), "iso-a4", or a numeric/undefined-typed value that stringifies oddly.

Common situations: Users assuming other paper sizes (Legal, A3, A5) are supported; copy-pasting "A4" with a trailing space or BOM from a spreadsheet; config written for another tool that accepts "iso-a4".

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16). Data as JSON: /api/errors/d3e8794488aa4062. Report an issue: GitHub.

Appendix: source

Thrown at generate-pdf.mjs:1463

  } catch (err) {
    if (err?.code !== 'ENOENT') throw err;
  }
  // One profile governs the whole batch, so the declared order is read once
  // rather than per entry. Anchored to workspaceRoot for the same reason the
  // single render is: it is the anchor readStyleTokens() and the cv.md read
  // already use, so one profile.yml supplies every setting.
  const cvSectionOrder = readCvSectionOrder(resolve(workspaceRoot, 'config', 'profile.yml'));

  for (let i = 0; i < manifest.length; i++) {
    const spec = manifest[i];
    try {
      if (!spec || typeof spec.input !== 'string' || typeof spec.output !== 'string') {
        throw new Error('each entry needs a string "input" and "output"');
      }

      const entryFormat = (spec.format || globals.format).toLowerCase();
      if (!validFormats.includes(entryFormat)) {
        throw new Error(`invalid format "${entryFormat}" (use: ${validFormats.join(', ')})`);
      }

      const entryReport = (spec.reportNum ?? '').toString().trim();
      if (entryReport && !/^\d+$/.test(entryReport)) {
        throw new Error(`invalid reportNum "${entryReport}" (use the numeric report number)`);
      }

      // Resolve manifest-supplied input/output relative to the manifest's own
      // directory, not process.cwd(), so a manifest renders identically wherever
      // the batch is launched from. Absolute paths in the manifest still win
      // (resolve() ignores the base when the tail is absolute).
      const entryInput = resolve(manifestDir, spec.input);
      const entryOutput = resolve(manifestDir, spec.output);

      // Path-containment guards (realpath-based): keep the read and write inside
      // the tracker workspace even through a symlinked ancestor. A batch
      // manifest that escapes the workspace is malformed/tampered and is
      // recorded as a per-entry failure rather than read or written.

View on GitHub (pinned to aac998c7ed)