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
- Fix the template syntax reported in problem/span
- Lint templates with ember-template-lint in CI to catch errors before unwrap
- Sanitize/validate dynamically supplied template sources
- 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
- Check template.result === 'error' before unwrapping when you have access to the result
- Lint dynamic template sources before compiling
- Pin compiler/syntax versions together
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
- Compile Error: ${error.problem} @ ${error.span.start}..${err
- b.concat requires at least one part
- ${open.path.original} doesn't match ${close}
- Invalid path: ${original}
- Compile Error: ${template.problem} @ ${template.span.start}.
AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01).
Data as JSON: /api/errors/e0ba2bff7b48e3fc.
Report an issue: GitHub.