santifer/career-ops · error

Unknown template kind

Error message

Unknown template kind: ${kind}

What it means

Generic kind guard in cv-templates.mjs template discovery: listTemplates was called with a template kind that has no configured directory/prefix mapping, so it cannot know where to look or what file prefix to match. The interpolated value is the unrecognized kind string — the caller passed something other than the known kinds (e.g. cv). It fires before any filesystem scan, so no files are consulted.

Solutions

  1. Check the spelling/casing of the kind argument at the call site — it must be one of the kinds with an entry in the kind config map
  2. Extend the kind config map in cv-templates.mjs if a genuinely new template category is being added
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cv-templates.mjs:207 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at cv-templates.mjs:207

// rather than settled by a precedence rule.
//
// Precedence would have to pick a winner while both files exist and both look
// correct — during a migration from a flat template to a pack, say — and the
// loser would simply stop being rendered, silently, with nothing in the output
// naming the file that won. Failing at discovery costs one clear error and
// makes the ambiguity impossible to ship past.
function assertNoCollision(name, a, b, dir) {
  const rel = (p) => p.slice(dir.length + 1) || p;
  const [x, y] = [rel(a), rel(b)].sort();
  throw new Error(
    `Template name "${name}" is claimed by two files: ${x} and ${y}. `
      + `A name must resolve to one template — rename one, or remove the one you no longer use.`
  );
}

export function listTemplates(kind, { dir = DEFAULT_TEMPLATES_DIR, format = 'html' } = {}) {
  const cfg = KINDS[kind];
  if (!cfg) throw new Error(`Unknown template kind: ${kind}`);
  assertFormat(format);
  return [...discover(kind, { dir, format }).values()].sort((a, b) => a.name.localeCompare(b.name));
}

export function validateTemplate(path, kind) {
  const cfg = KINDS[kind];
  if (!cfg) throw new Error(`Unknown template kind: ${kind}`);
  const text = readFileSync(path, 'utf-8');
  const missing = cfg.required.filter((ph) => !text.includes(`{{${ph}}}`));
  return { ok: missing.length === 0, missing };
}

export function loadProfileDefault(kind, { profilePath = DEFAULT_PROFILE_PATH } = {}) {
  const cfg = KINDS[kind];
  if (!cfg) throw new Error(`Unknown template kind: ${kind}`);
  if (!existsSync(profilePath)) return null;
  let doc;
  try {

View on GitHub (pinned to aac998c7ed)