{"record":{"id":"46141f6d43dfe53b","repo":"ethereum/go-ethereum","slug":"invalid-node-type","errorCode":null,"errorMessage":"invalid node type","messagePattern":"invalid node type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"trie/stacktrie.go","lineNumber":403,"sourceCode":"\t\t\tVal: st.children[0].val,\n\t\t}\n\t\tn.encode(t.h.encbuf)\n\t\tblob = t.h.encodedBytes()\n\n\t\tstPool.Put(st.children[0].reset()) // Release child back to pool.\n\t\tst.children[0] = nil\n\n\tcase leafNode:\n\t\tst.key = append(st.key, byte(16))\n\t\tn := leafNodeEncoder{\n\t\t\tKey: hexToCompactInPlace(st.key),\n\t\t\tVal: st.val,\n\t\t}\n\t\tn.encode(t.h.encbuf)\n\t\tblob = t.h.encodedBytes()\n\n\tdefault:\n\t\tpanic(\"invalid node type\")\n\t}\n\t// Convert the node type to hashNode and reset the key slice.\n\tst.typ = hashedNode\n\tst.key = st.key[:0]\n\n\t// Release reference to value slice which is exclusively owned\n\t// by stackTrie itself.\n\tif cap(st.val) > 0 && t.vPool != nil {\n\t\tt.vPool.put(st.val)\n\t}\n\tst.val = nil\n\n\t// Skip committing the non-root node if the size is smaller than 32 bytes\n\t// as tiny nodes are always embedded in their parent except root node.\n\tif len(blob) < 32 && len(path) > 0 {\n\t\tst.val = bPool.getWithSize(len(blob))\n\t\tcopy(st.val, blob)\n\t\treturn","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/ethereum/go-ethereum/blob/6bb0588ad8e7f922e4ad5580f51265a4097af08f/trie/stacktrie.go#L385-L421","documentation":"Error \"invalid node type\" thrown in ethereum/go-ethereum.","triggerScenarios":"Hashing a stacktrie node whose type does not match any known stNode kind.","commonSituations":"Internal corruption or misuse of the stacktrie API outside its contract.","solutions":["Defensive panic for an unknown node type during stacktrie hashing. Use the StackTrie correctly (sorted unique keys, no insertion after Hash) and treat any hit of this panic as an internal bug to report."],"exampleFix":"// Ensure single-threaded, sorted, one-shot usage:\nst := stacktrie.New(nil)\nfor _, kv := range sortedUniqueKVs { st.Update(kv.K, kv.V) }\nroot := st.Hash()","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6bb0588ad8e7f922e4ad5580f51265a4097af08f","analyzedAt":"2026-08-15T10:06:53.996Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}