gohugoio/hugo · critical

Shift: unknown type %T for %q

Error message

Shift: unknown type %T for %q

What it means

An internal panic in contentNodeShifter.Shift (hugolib/content_map_page_contentnodeshifter.go:160) when the node does not implement contentNodeLookupContentNode. The %T prints the node type and %q prints its Path() so the offending node is identifiable.

Source

Thrown at hugolib/content_map_page_contentnodeshifter.go:160

			s := make(contentNodes, 0, len(vv)+1)
			for _, v := range vv {
				s = append(s, v)
			}
			s = append(s, new)
			return s, vv, false
		}
	default:
		panic(fmt.Sprintf("Insert: unknown type %T", old))
	}
}

func (s *contentNodeShifter) Shift(n contentNode, siteVector sitesmatrix.Vector, fallback bool) (contentNode, bool) {
	var exact contentNode
	switch v := n.(type) {
	case contentNodeLookupContentNode:
		exact = v.lookupContentNode(siteVector)
	default:
		panic(fmt.Sprintf("Shift: unknown type %T for %q", n, n.Path()))
	}

	if exact != nil {
		if !fallback {
			return exact, true
		}
		// If the exact match is backed by a file, return it directly.
		if wp, ok := exact.(contentNodeContentWeightProvider); ok && wp.contentWeight() > 0 {
			return exact, true
		}
		// The exact match is an auto page (not backed by a file).
		// Check if there's a file-backed complement that should take precedence.
		if vvv := cnh.findContentNodeForSiteVector(siteVector, fallback, cnh.contentNodeToSeq(n)); vvv != nil {
			return vvv, true
		}
		return exact, true
	}

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Report a Hugo bug with the path shown in the panic
  2. Ensure all shiftable nodes implement contentNodeLookupContentNode
  3. Upgrade Hugo
Defensive patterns

Strategy: type-guard

Validate before calling

// Internal: ensure n implements contentNodeLookupContentNode before Shift.
if _, ok := n.(contentNodeLookupContentNode); !ok {
    return nil, false
}

Type guard

func isShiftable(n contentNode) bool {
    _, ok := n.(contentNodeLookupContentNode)
    return ok
}

Prevention

When it happens

Trigger: Shift receives a node that does not implement contentNodeLookupContentNode — an internal contract violation during dimension shifting.

Common situations: Hugo internal bug; a custom node type lacking the required interface.

Related errors


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