{"record":{"id":"b1aa54d392cac8a0","repo":"emberjs/ember.js","slug":"unexpected-node-type-value-type-found-when-ac","errorCode":null,"errorMessage":"Unexpected node type \"${value.type}\" found when accepting ${name} on ${node.type}","messagePattern":"Unexpected node type \"(.+?)\" found when accepting (.+?) on (.+?)","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"packages/@handlebars/parser/lib/visitor.js","lineNumber":18,"sourceCode":"import Exception from './exception.js';\n\nfunction Visitor() {\n  this.parents = [];\n}\n\nVisitor.prototype = {\n  constructor: Visitor,\n  mutating: false,\n\n  // Visits a given value. If mutating, will replace the value if necessary.\n  acceptKey: function (node, name) {\n    let value = this.accept(node[name]);\n    if (this.mutating) {\n      // Hacky sanity check: This may have a few false positives for type for the helper\n      // methods but will generally do the right thing without a lot of overhead.\n      if (value && !Visitor.prototype[value.type]) {\n        throw new Exception(\n          'Unexpected node type \"' +\n            value.type +\n            '\" found when accepting ' +\n            name +\n            ' on ' +\n            node.type\n        );\n      }\n      node[name] = value;\n    }\n  },\n\n  // Performs an accept operation with added sanity check to ensure\n  // required keys are not removed.\n  acceptRequired: function (node, name) {\n    this.acceptKey(node, name);\n\n    if (!node[name]) {","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@handlebars/parser/lib/visitor.js#L1-L36","documentation":"The visitor's acceptKey sanity check (active when the visitor is mutating) verifies that any node produced while traversing a key has a registered visitor handler. If a child value has an unknown node type, it throws rather than silently corrupting the AST during mutation passes.","triggerScenarios":"A mutating Visitor pass (whitespace control, transforms, ember-template-recast-style edits) sets a node key to a value whose .type has no Visitor.prototype handler, or hand-builds AST nodes with a typo'd type field.","commonSituations":"Custom AST transforms inserting malformed nodes; plugins/glint/codemods operating on templates; version mismatch where a new node type isn't handled by an older visitor.","solutions":["Fix the transform to only insert nodes with valid, registered types (e.g. 'MustacheStatement', 'PathExpression')","Check the type string for typos on hand-constructed nodes","Update visitor/transform packages so versions match the parser AST spec","Temporarily run non-mutating to inspect the AST and find the offending node"],"exampleFix":"// before\nnode.params.push({ type: 'mustache', original: 'x' });\n// after\nnode.params.push({ type: 'SubExpression', path: { type: 'PathExpression', original: 'x', data: false, depth: 0, parts: ['x'], loc: null }, params: [], hash: { type: 'Hash', pairs: [], loc: null }, loc: null });","handlingStrategy":"validation","validationCode":"const VALID = new Set(['Program','MustacheStatement','BlockStatement','PartialBlockStatement','PartialStatement','CommentStatement','MustacheCommentStatement','DecoratorBlock','Decorator','ElementNode','AttrNode','TextNode','ConcatStatement','SubExpression','PathExpression','Hash','HashPair','BooleanLiteral','NumberLiteral','StringLiteral','UndefinedLiteral','NullLiteral','Block']);\nfunction validNode(n) { return n == null || VALID.has(n.type); }","typeGuard":"function isAstNode(v) { return v != null && typeof v.type === 'string' && Visitor.prototype[v.type] !== undefined; }","tryCatchPattern":"try { visitor.visit(ast); } catch (e) { if (/Unexpected node type/.test(e.message)) { dumpAstAtError(ast, e.message); } throw e; }","preventionTips":["Only insert nodes whose type exists in the visitor map","Copy node shapes from the parser's own output, don't hand-roll","Keep transform/parser package versions in sync","Run non-mutating traversal in tests to validate ASTs"],"tags":["ast","visitor","handlebars","parser"],"backgroundTag":"unknown-ast-node-type","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}