{"record":{"id":"15b35fdb1390ba10","repo":"handlebars-lang/handlebars.js","slug":"unknown-type-node-type","errorCode":null,"errorMessage":"Unknown type: ${node.type}","messagePattern":"Unknown type: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"lib/handlebars/compiler/compiler.js","lineNumber":90,"sourceCode":"  },\n\n  compileProgram: function (program) {\n    let childCompiler = new this.compiler(),\n      result = childCompiler.compile(program, this.options),\n      guid = this.guid++;\n\n    this.usePartial = this.usePartial || result.usePartial;\n\n    this.children[guid] = result;\n    this.useDepths = this.useDepths || result.useDepths;\n\n    return guid;\n  },\n\n  accept: function (node) {\n    /* v8 ignore next -- Sanity code */\n    if (!this[node.type]) {\n      throw new Exception('Unknown type: ' + node.type, node);\n    }\n\n    this.sourceNode.unshift(node);\n    let ret = this[node.type](node);\n    this.sourceNode.shift();\n    return ret;\n  },\n\n  Program: function (program) {\n    this.options.blockParams.unshift(program.blockParams);\n\n    let body = program.body,\n      bodyLength = body.length;\n    for (let i = 0; i < bodyLength; i++) {\n      this.accept(body[i]);\n    }\n\n    this.options.blockParams.shift();","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/handlebars-lang/handlebars.js/blob/13a7a679910d2adbfe7f6fad61ce8f98426b0378/lib/handlebars/compiler/compiler.js#L72-L108","documentation":"Thrown by the compiler's accept dispatcher when an AST node's type has no corresponding compiler method (this[node.type] is undefined). It fires when the input AST contains a node type the compiler does not implement — typically a corrupt, truncated, or hand-crafted AST, or an AST produced by a mismatched Handlebars parser/compiler version. It is an internal invariant/sanity guard, not an indication of bad template syntax alone; regenerate the AST with a matching Handlebars version.","triggerScenarios":"Passing a hand-built or third-party-generated AST to Handlebars.compile/precompile whose nodes have types not in the Handlebars AST spec (e.g. type 'Root' instead of 'Program').","commonSituations":"ASTs produced by different Handlebars/Handlebars-like parser versions; ASTs mutated or serialized incorrectly; passing a Babel/other AST by mistake.","solutions":["Regenerate the AST with the same Handlebars version's parser instead of passing a foreign AST.","Pass the template string to compile() and let Handlebars parse it itself.","Check every node.type against the Handlebars AST spec (Program, MustacheStatement, etc.) and fix mismatched names.","If walking an AST, check ast.version to confirm it is a Handlebars AST."],"exampleFix":"// before\nHandlebars.precompile(foreignAst);\n// after\nHandlebars.precompile(templateSourceString);","handlingStrategy":"type-guard","validationCode":"function isHandlebarsAst(ast) {\n  return ast && typeof ast === 'object' && ast.type === 'Program' && typeof ast.body === 'array' !== false;\n}\n// Only pass handlebars.handlebars.parse(src) output, never foreign ASTs.","typeGuard":"function isHandlebarsProgram(n) { return n !== null && typeof n === 'object' && n.type === 'Program'; }","tryCatchPattern":"try { return Handlebars.compile(ast)(data); } catch (e) { if (/Unknown type/.test(e.message)) { return Handlebars.compile(sourceString)(data); } throw e; }","preventionTips":["Prefer compiling template strings over hand-built ASTs.","Verify ast.version when consuming serialized ASTs.","Never pass ASTs from other tools (Babel, etc.) to Handlebars.compile."],"tags":["ast","compiler","parser"],"backgroundTag":"unknown-ast-node-type","analyzedSha":"13a7a679910d2adbfe7f6fad61ce8f98426b0378","analyzedAt":"2026-09-02T20:25:07.518Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}