yamadashy/repomix · error · RepomixError

Unsupported output style for handlebars template: ${style}

Error message

Unsupported output style for handlebars template: ${style}

What it means

getCompiledTemplate selects a Handlebars template based on the requested output style. Only markdown and plain are supported for Handlebars rendering; any other style string reaching this function has no template, so it throws a RepomixError immediately.

Source

Thrown at src/core/output/outputGenerate.ts:47

const getCompiledTemplate = (style: string): Handlebars.TemplateDelegate => {
  const cached = compiledTemplateCache.get(style);
  if (cached) {
    return cached;
  }

  let template: string;
  switch (style) {
    case 'xml':
      template = getXmlTemplate();
      break;
    case 'markdown':
      template = getMarkdownTemplate();
      break;
    case 'plain':
      template = getPlainTemplate();
      break;
    default:
      throw new RepomixError(`Unsupported output style for handlebars template: ${style}`);
  }

  const compiled = Handlebars.compile(template);
  compiledTemplateCache.set(style, compiled);
  return compiled;
};

// The Markdown template wraps file contents, the directory structure, and git
// diffs in the same code fence, so the delimiter has to be longer than the
// longest backtick run across all of them. A diff of a Markdown file, for
// example, carries bare ``` context lines that would otherwise close the fence
// early and corrupt the output.
const calculateMarkdownDelimiter = (contents: ReadonlyArray<string | undefined>): string => {
  const maxBackticks = contents
    .flatMap((content) => content?.match(/`+/g) ?? [])
    .reduce((max, match) => Math.max(max, match.length), 0);
  return '`'.repeat(Math.max(3, maxBackticks + 1));
};

View on GitHub (pinned to f465ad9093)

Solutions

  1. Use style 'markdown' or 'plain' when rendering via the Handlebars path.
  2. Render 'xml'/'json' styles through generateParsableXmlOutput/generateParsableJsonOutput instead.
  3. Validate config.output.style against the allowed set before calling the generator.
  4. Fix typos in the config file's output.style value.

Example fix

// before
await generateHandlebarOutput({...config, output: {...config.output, style: 'xml'}}, ctx, files);
// after
await generateParsableXmlOutput(ctx); // or style: 'markdown'
Defensive patterns

Strategy: validation

Validate before calling

const HANDLEBAR_STYLES = ['markdown', 'plain'] as const;
if (!HANDLEBAR_STYLES.includes(style as never)) {
  throw new Error(`Handlebars path supports only ${HANDLEBAR_STYLES.join('/')}, got ${style}`);
}

Type guard

const isHandlebarStyle = (s: string): s is 'markdown' | 'plain' =>
  s === 'markdown' || s === 'plain';

Try / catch

try {
  const output = await generateOutput(config, ctx);
} catch (e) {
  if (e instanceof RepomixError && e.message.startsWith('Unsupported output style for handlebars')) {
    // route xml/json to the parsable generators or correct the style
  }
}

Prevention

When it happens

Trigger: getCompiledTemplate(style) is called with a style other than 'markdown' or 'plain' — e.g. 'xml', 'json', or an arbitrary string from config.output.style routed into generateHandlebarOutput.

Common situations: Programmatic use of the output generator API with a raw style string; a config file with a misspelled style ('markdwon'); custom tooling that bypasses generateOutput's switch dispatch.

Related errors


AI-assisted analysis of yamadashy/repomix@f465ad9093 (2026-08-29). Data as JSON: /api/errors/c3dbb5422ce90091. Report an issue: GitHub.