emberjs/ember.js · error · Error

Compile Error: ${template.problem} @ ${template.span.start}.

Error message

Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}

What it means

unwrapTemplate unwraps a Template result, and if the result is an error variant it throws a Compile Error containing the template's problem and source span. Like unwrapHandle, this converts compiler failures into an explicit runtime exception instead of silently returning a broken template.

Source

Thrown at packages/@glimmer/debug-util/lib/template.ts:14

import type { ErrHandle, HandleResult, OkHandle, Template, TemplateOk } from '@glimmer/interfaces';

export function unwrapHandle(handle: HandleResult): number {
  if (typeof handle === 'number') {
    return handle;
  } else {
    let error = handle.errors[0];
    throw new Error(`Compile Error: ${error.problem} @ ${error.span.start}..${error.span.end}`);
  }
}

export function unwrapTemplate(template: Template): TemplateOk {
  if (template.result === 'error') {
    throw new Error(
      `Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`
    );
  }

  return template;
}

export function extractHandle(handle: HandleResult): number {
  if (typeof handle === 'number') {
    return handle;
  } else {
    return handle.handle;
  }
}

export function isOkHandle(handle: HandleResult): handle is OkHandle {
  return typeof handle === 'number';
}

View on GitHub (pinned to 26f97246a8)

Solutions

  1. Fix the template syntax reported in problem/span
  2. Lint templates with ember-template-lint in CI to catch errors before unwrap
  3. Sanitize/validate dynamically supplied template sources
  4. Upgrade glimmer-vm if the template uses newer syntax than the compiler supports

Example fix

// before
{{each items as |item|}}
  {{item.name}
// after
{{#each items as |item|}}
  {{item.name}}
{{/each}}
Defensive patterns

Strategy: try-catch

Type guard

function isTemplateOk(t) { return t.result === 'ok'; }

Try / catch

try {
  let ok = unwrapTemplate(template);
} catch (e) {
  if (String(e.message).startsWith('Compile Error:')) {
    reportTemplateError(template.problem, template.span);
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling unwrapTemplate on a template produced by the Glimmer compiler whose result === 'error' — i.e., the template source failed to parse/compile.

Common situations: Template syntax errors in precompiled bundles; dynamically compiled templates (e.g. from user input or CMS content) that are invalid; version mismatch between compiler and syntax features used.

Related errors


AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01). Data as JSON: /api/errors/e0ba2bff7b48e3fc. Report an issue: GitHub.