gohugoio/hugo · error

metadata decoding failed: %v

Error message

metadata decoding failed: %v

What it means

Decoder.DecodeMeta decodes metadata from all sources (EXIF, IPTC, XMP) and, like Decode, wraps the whole operation in a deferred recover(). This error means the imagemeta library panicked while parsing one of those metadata blocks and Hugo surfaced the panic as an error rather than crashing.

Source

Thrown at resources/images/meta/meta.go:305

	tags := make(map[string]any)
	for k, v := range tagInfos.All() {
		if !d.shouldIncludeField(k) {
			continue
		}
		tags[k] = v.Value
	}

	ex = &ExifInfo{Lat: lat, Long: long, Date: tm, Tags: tags}

	return
}

// DecodeMeta decodes metadata from all sources (EXIF, IPTC, XMP).
// Filename is only used for logging.
func (d *Decoder) DecodeMeta(filename string, format imagemeta.ImageFormat, r io.Reader) (m *MetaInfo, err error) {
	defer func() {
		if r := recover(); r != nil {
			err = fmt.Errorf("metadata decoding failed: %v", r)
		}
	}()

	var tagInfos imagemeta.Tags
	handleTag := func(ti imagemeta.TagInfo) error {
		tagInfos.Add(ti)
		return nil
	}

	shouldHandleTag := func(ti imagemeta.TagInfo) bool {
		// For EXIF, only include tags from IFD0 (skip thumbnail data).
		if ti.Source == imagemeta.EXIF {
			if !strings.HasPrefix(ti.Namespace, "IFD0") {
				return false
			}
		}

		return d.shouldIncludeField(ti.Tag)

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Find the named file in the log and strip or rewrite its metadata (`exiftool -all= file.jpg`), then rebuild.
  2. Confirm the file is intact and its extension matches its real format.
  3. Upgrade Hugo to pick up imagemeta parser fixes; report reproducible panics upstream with the image attached.
Defensive patterns

Strategy: try-catch

Try / catch

md, err := decodeMetadata(r)
if err != nil {
    log.Printf("metadata decode failed for %s: %v", name, err)
    // treat image as having no metadata; do not abort processing
}

Prevention

When it happens

Trigger: Accessing an image resource's full metadata (the newer meta API covering EXIF+IPTC+XMP) on a file whose metadata segment triggers a parser panic — malformed XMP XML packets, corrupt IPTC records, or broken EXIF IFDs.

Common situations: Images processed by asset pipelines that write nonstandard XMP, stock photos with vendor-specific IPTC blocks, truncated downloads, or regressions/changes after a Hugo upgrade bumped the bundled imagemeta version.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/cf8fab3da129ed2e.json. Report an issue: GitHub ↗.