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 asserts the template compiled successfully; if the template's compile result is an error, it throws with the compiler's problem and source span. It converts a lazy compile failure into an immediate, descriptive error.

Source

Thrown at packages/@ember/-internals/glimmer/lib/component-managers/unwrap-template.ts:8

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

/**
 * @deprecated
 */
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;
}

View on GitHub (pinned to 26f97246a8)

Solutions

  1. Fix the template syntax error reported in `problem` at the given span
  2. Rebuild (ember build/serve) to clear stale compilation artifacts
  3. If compiling templates at runtime, validate/compile with setTemplate/compile first and handle errors
  4. Check the addon providing the dynamic layout for version compatibility

Example fix

// before
{{#if this.user
  <p>hi</p>
{{/if}}
// after
{{#if this.user}}
  <p>hi</p>
{{/if}}
Defensive patterns

Strategy: try-catch

Validate before calling

if (template && template.result === 'error') { console.error(template.problem, template.span); }

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Passing a template object whose compilation failed (syntax error in a handlebars/glimmer template) into unwrapTemplate via templateFor, getDynamicLayout, or component construction with a dynamic layout.

Common situations: Typo in handlebars syntax (unclosed block, bad {{#if}}), invalid component layout strings, build pipeline producing error template results, runtime-compiled templates from addon code.

Related errors


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