{"record":{"id":"7ebbb619329f680f","repo":"gohugoio/hugo","slug":"contentnodetocontentnodespage-unexpected-type-t","errorCode":null,"errorMessage":"contentNodeToContentNodesPage: unexpected type %T","messagePattern":"contentNodeToContentNodesPage: unexpected type %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hugolib/content_map_page_contentnode.go","lineNumber":395,"sourceCode":"func (n contentNodesMap) isEmpty() bool {\n\treturn len(n) == 0\n}\n\nfunc absint(i int) int {\n\tif i < 0 {\n\t\treturn -i\n\t}\n\treturn i\n}\n\nfunc contentNodeToContentNodesPage(n contentNode) (contentNodesMap, bool) {\n\tswitch v := n.(type) {\n\tcase contentNodesMap:\n\t\treturn v, false\n\tcase *pageState:\n\t\treturn contentNodesMap{v.s.siteVector: v}, true\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"contentNodeToContentNodesPage: unexpected type %T\", n))\n\t}\n}\n\n// hasAutoContentNode reports whether n holds at least one node that is not backed by a file.\nfunc (h helperContentNode) hasAutoContentNode(n contentNodeForEach) bool {\n\treturn !n.forEeachContentNode(func(_ sitesmatrix.Vector, nn contentNode) bool {\n\t\twp, ok := nn.(contentNodeContentWeightProvider)\n\t\treturn ok && wp.contentWeight() > 0\n\t})\n}\n\nfunc (h helperContentNode) contentNodeToSeq(n contentNodeForEach) contentNodeSeq {\n\tif nn, ok := n.(contentNodeSeq); ok {\n\t\treturn nn\n\t}\n\treturn func(yield func(contentNode) bool) {\n\t\tn.forEeachContentNode(func(_ sitesmatrix.Vector, nn contentNode) bool {\n\t\t\treturn yield(nn)","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugolib/content_map_page_contentnode.go#L377-L413","documentation":"An internal panic in contentNodeToContentNodesPage (hugolib/content_map_page_contentnode.go:395). The function narrows a contentNode to a contentNodesMap but only knows how to handle the concrete types contentNodesMap and *pageState; any other type triggers the panic. This is an invariant of Hugo's page content tree.","triggerScenarios":"A contentNode implementation other than contentNodesMap or *pageState is placed in the page tree and later narrowed. Not reachable through normal user content or configuration.","commonSituations":"Hugo internal bug, a broken intermediate build, or a custom hook/plugin injecting an unexpected node type. Almost exclusively seen during Hugo development.","solutions":["Report a Hugo bug with the content/layout that reproduces it","Ensure any custom contentNode implementation satisfies the expected type set","Upgrade to a released Hugo version rather than a custom build"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Internal: ensure n is one of the handled types before narrowing.\nswitch n.(type) {\ncase contentNodesMap, *pageState:\ndefault:\n    panic(fmt.Sprintf(\"unexpected contentNode type %T\", n))\n}","typeGuard":"func isNarrowableContentNode(n contentNode) bool {\n    switch n.(type) {\n    case contentNodesMap, *pageState:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["This is an internal invariant; report bugs rather than working around them","Keep custom contentNode implementations within the recognized type set","Add unit tests covering all node types when extending the content map"],"tags":["hugolib","content-map","internal","panic"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}