emberjs/ember.js · error · Exception
Invalid path: ${original}
Error message
Invalid path: ${original} What it means
Handlebars paths may not contain '..', '.', or 'this' as non-final segments; such segments would produce an ambiguous or invalid path. preparePath throws 'Invalid path' with the accumulated original path text when it encounters one of these segments after other segments.
Source
Thrown at packages/@handlebars/parser/lib/helpers.js:73
}
let tail = [];
let depth = 0;
for (let i = 0, l = parts.length; i < l; i++) {
let part = parts[i].part;
// If we have [] syntax then we do not treat path references as operators,
// i.e. foo.[this] resolves to approximately context.foo['this']
let isLiteral = parts[i].original !== part;
let separator = parts[i].separator;
let partPrefix = separator === '.#' ? '#' : '';
original += (separator || '') + part;
if (!isLiteral && (part === '..' || part === '.' || part === 'this')) {
if (tail.length > 0) {
throw new Exception('Invalid path: ' + original, { loc });
} else if (part === '..') {
depth++;
}
} else {
tail.push(`${partPrefix}${part}`);
}
}
let head = sexpr || tail.shift();
return {
type: 'PathExpression',
this: original.startsWith('this.'),
data,
depth,
head,
tail,
parts: head ? [head, ...tail] : tail,View on GitHub (pinned to 26f97246a8)
Solutions
- Remove '..'/'.'/ 'this' from the middle of the path; bind the needed context explicitly
- Use {{this.foo}} only as the whole leading segment, not nested: this.foo.bar is fine, foo.this is not
- Compute derived values in JS (getter/component property) instead of complex paths
- Split the expression: pass the object as a block param and access simple properties on it
Example fix
// before
{{article..title}}
// after
{{#let this.article as |article|}}
{{article.title}}
{{/let}} Defensive patterns
Strategy: validation
Validate before calling
if (/\.{1,2}|\bthis\b/.test(path.replace(/^(this\.)|(\.|\.\.)/, ''))) throw new Error('Invalid mid-path segment: ' + path); Try / catch
try { parse(src); } catch (e) { if (/Invalid path/.test(e.message)) { console.error('Fix path near', e.loc || 'unknown'); } throw e; } Prevention
- Avoid '..' parent navigation — bind contexts with block params instead
- Use {{this.foo}} only as a leading segment
- Precompute complex lookups in JS getters
When it happens
Trigger: Writing paths like {{foo./bar}}, {{a..b}}, {{this.foo.this}}, or a path where '..' / '.' / 'this' appears mid-path (tail.length > 0) rather than as the whole path.
Common situations: Attempting relative-path navigation from Ember templates (not supported); typos like {{item..name}}; migrating templates from other templating languages that allow parent traversal.
Related errors
- ${open.path.original} doesn't match ${close}
- Compile Error: ${error.problem} @ ${error.span.start}..${err
- Compile Error: ${template.problem} @ ${template.span.start}.
- Unexpected inverse block on decorator
- b.concat requires at least one part
AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01).
Data as JSON: /api/errors/5492b47a58a83e54.
Report an issue: GitHub.