davila7/claude-code-templates · error · Error

Unknown language template: ${language}

Error message

Unknown language template: ${language}

What it means

Thrown by getTemplateConfig() in cli-tool/src/templates.js when the 'language' key of the selections object has no entry in TEMPLATES_CONFIG. The template system only supports the languages registered in that config map; any other string (or undefined) is rejected before any files are generated.

Source

Thrown at cli-tool/src/templates.js:146

  }));
}

function getFrameworksForLanguage(language) {
  const config = TEMPLATES_CONFIG[language];
  if (!config || !config.frameworks) return [];
  
  return Object.keys(config.frameworks).map(key => ({
    value: key,
    name: config.frameworks[key].name
  }));
}

function getTemplateConfig(selections) {
  const { language, framework, commands = [] } = selections;
  const baseConfig = TEMPLATES_CONFIG[language];
  
  if (!baseConfig) {
    throw new Error(`Unknown language template: ${language}`);
  }
  
  let files = [...baseConfig.files];
  
  // Add framework-specific files
  if (framework && framework !== 'none' && baseConfig.frameworks && baseConfig.frameworks[framework]) {
    const frameworkConfig = baseConfig.frameworks[framework];
    if (frameworkConfig.additionalFiles) {
      files = files.concat(frameworkConfig.additionalFiles);
    }
  }
  
  // Handle command selection
  let selectedCommands = [];
  if (commands && commands.length > 0) {
    const availableCommands = getCommandsForLanguageAndFramework(language, framework);
    selectedCommands = availableCommands.filter(cmd => commands.includes(cmd.name));
  }

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Log and inspect selections.language — fix typos and use exact lowercase keys as defined in TEMPLATES_CONFIG in cli-tool/src/templates.js
  2. Add the missing language entry to TEMPLATES_CONFIG if it should be supported
  3. Validate the language against Object.keys(TEMPLATES_CONFIG) before calling getTemplateConfig

Example fix

// before
const baseConfig = TEMPLATES_CONFIG[language];
if (!baseConfig) {
  throw new Error(`Unknown language template: ${language}`);
}

// after
const baseConfig = TEMPLATES_CONFIG[language];
if (!baseConfig) {
  const supported = Object.keys(TEMPLATES_CONFIG).join(', ');
  throw new Error(`Unknown language template: ${language}. Supported: ${supported}`);
}
Defensive patterns

Strategy: validation

Validate before calling

const { TEMPLATES_CONFIG } = require('./templates');
if (!Object.prototype.hasOwnProperty.call(TEMPLATES_CONFIG, language)) {
  throw new Error(`Unsupported language '${language}'. Choose from: ${Object.keys(TEMPLATES_CONFIG).join(', ')}`);
}
const cfg = getTemplateConfig({ language, framework, commands });

Type guard

function isSupportedLanguage(lang) {
  return typeof lang === 'string' && Object.prototype.hasOwnProperty.call(TEMPLATES_CONFIG, lang);
}

Try / catch

try {
  const cfg = getTemplateConfig(selections);
} catch (e) {
  if (/Unknown language template/.test(e.message)) {
    const supported = Object.keys(TEMPLATES_CONFIG).join(', ');
    throw new Error(`${e.message}. Supported languages: ${supported}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getTemplateConfig({language: 'rust'}) when TEMPLATES_CONFIG only defines e.g. javascript/typescript/python; passing selections without a language (undefined); a typo or case mismatch ('JavaScript' vs 'javascript').

Common situations: User input from an interactive prompt or CLI flag containing an unsupported language; version drift where a template name was renamed but callers still pass the old key; scripting the API directly with a guessed language name.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/c84f0efd46e1be7d. Report an issue: GitHub.