gohugoio/hugo · critical

DeleteFunc: unknown type %T

Error message

DeleteFunc: unknown type %T

What it means

An internal panic in contentNodeShifter.DeleteFunc (hugolib/content_map_page_contentnodeshifter.go:88). The shifter's DeleteFunc handles contentNodeSingle, contentNodes, and contentNodesMap; the default branch panics naming the unrecognized type, enforcing the shifter contract for the doctree.

Source

Thrown at hugolib/content_map_page_contentnodeshifter.go:88

		return false
	case contentNodes:
		for i, n := range ss {
			if f(n) {
				resource.MarkStale(n)
				ss = append(ss[:i], ss[i+1:]...)
			}
		}
		return len(ss) == 0
	case contentNodesMap:
		for k, n := range ss {
			if f(n) {
				resource.MarkStale(n)
				delete(ss, k)
			}
		}
		return len(ss) == 0
	default:
		panic(fmt.Sprintf("DeleteFunc: unknown type %T", v))
	}
}

func (s *contentNodeShifter) ForEeachInAllDimensions(n contentNode, f func(contentNode) bool) {
	if n == nil {
		return
	}
	if v, ok := n.(interface {
		// Implemented by all the list nodes.
		ForEeachInAllDimensions(f func(contentNode) bool)
	}); ok {
		v.ForEeachInAllDimensions(f)
		return
	}
	f(n)
}

func (s *contentNodeShifter) ForEeachInDimension(n contentNode, vec sitesmatrix.Vector, d int, f func(contentNode) bool) {

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Report a Hugo bug
  2. Ensure all contentNode types placed in the tree are one of the handled categories
  3. Upgrade Hugo
Defensive patterns

Strategy: type-guard

Validate before calling

// Internal: type-switch before calling DeleteFunc-equivalent logic.
switch v.(type) {
case contentNodeSingle, contentNodes, contentNodesMap:
default:
    return false // or handle gracefully
}

Type guard

func isShiftableForDelete(v contentNode) bool {
    switch v.(type) {
    case contentNodeSingle, contentNodes, contentNodesMap:
        return true
    }
    return false
}

Prevention

When it happens

Trigger: Passing a contentNode of an unregistered type into the shifter's DeleteFunc — an internal contract violation, not reachable via user content.

Common situations: Hugo internal bug or a custom shifter/node extension; not triggered by normal builds.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/053d460567961349. Report an issue: GitHub.