{"record":{"id":"cf8fab3da129ed2e","repo":"gohugoio/hugo","slug":"metadata-decoding-failed-v","errorCode":null,"errorMessage":"metadata decoding failed: %v","messagePattern":"metadata decoding failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/meta/meta.go","lineNumber":305,"sourceCode":"\ttags := make(map[string]any)\n\tfor k, v := range tagInfos.All() {\n\t\tif !d.shouldIncludeField(k) {\n\t\t\tcontinue\n\t\t}\n\t\ttags[k] = v.Value\n\t}\n\n\tex = &ExifInfo{Lat: lat, Long: long, Date: tm, Tags: tags}\n\n\treturn\n}\n\n// DecodeMeta decodes metadata from all sources (EXIF, IPTC, XMP).\n// Filename is only used for logging.\nfunc (d *Decoder) DecodeMeta(filename string, format imagemeta.ImageFormat, r io.Reader) (m *MetaInfo, err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"metadata decoding failed: %v\", r)\n\t\t}\n\t}()\n\n\tvar tagInfos imagemeta.Tags\n\thandleTag := func(ti imagemeta.TagInfo) error {\n\t\ttagInfos.Add(ti)\n\t\treturn nil\n\t}\n\n\tshouldHandleTag := func(ti imagemeta.TagInfo) bool {\n\t\t// For EXIF, only include tags from IFD0 (skip thumbnail data).\n\t\tif ti.Source == imagemeta.EXIF {\n\t\t\tif !strings.HasPrefix(ti.Namespace, \"IFD0\") {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\treturn d.shouldIncludeField(ti.Tag)","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/meta/meta.go#L287-L323","documentation":"Returned (not panicked) by Decoder.DecodeMeta when the underlying multi-source metadata parser (EXIF + IPTC + XMP) panics. The deferred recover() at meta.go:305 catches the panic and converts it to an error with %v formatting. This is the newer multi-source metadata path, as opposed to the EXIF-only Decode method that produces error 554.","triggerScenarios":"An image with malformed metadata in any of the configured sources (EXIF, IPTC, or XMP) causes the parser to panic during DecodeMeta. This path is used when imaging.meta.sources includes iptc or xmp in addition to exif.","commonSituations":"Enabling XMP source parsing (imaging.meta.sources = ['exif','iptc','xmp']) on images with corrupt XMP packets; images with IPTC-IIM data that violates the spec; HEIC-to-JPEG conversions that produce malformed XMP RDF.","solutions":["Strip problematic metadata with exiftool: 'exiftool -overwrite_original -all= path/to/image.jpg' then re-add what you need.","Narrow imaging.meta.sources to only the sources you need — if XMP is causing failures, remove it: sources = ['exif', 'iptc'].","Re-export the image with a reliable converter to produce clean metadata blocks.","Use imaging.meta.fields patterns to exclude the specific fields that trigger the panic."],"exampleFix":"# before (hugo.toml) — XMP parsing causes panic on some images\n[imaging.meta]\nsources = [\"exif\", \"iptc\", \"xmp\"]\n\n# after — drop XMP (the slowest and most failure-prone source)\n[imaging.meta]\nsources = [\"exif\", \"iptc\"]","handlingStrategy":"try-catch","validationCode":"// Pre-validate metadata before Hugo's DecodeMeta\n// From the shell, check IPTC/XMP integrity:\n// exiftool -verbose path/to/image.jpg 2>&1 | grep -i 'error|warning'\n\n// Or restrict Hugo to EXIF+IPTC only (drop XMP, the most failure-prone):\n// In hugo.toml:\n// [imaging.meta]\n// sources = [\"exif\", \"iptc\"]","typeGuard":null,"tryCatchPattern":"// DecodeMeta recovers internally and returns an error.\n// Handle gracefully:\nmetaInfo, err := decoder.DecodeMeta(filename, format, reader)\nif err != nil {\n    // err contains 'metadata decoding failed: <panic message>'\n    log.Printf(\"warning: metadata decode failed for %s: %v\", filename, err)\n    metaInfo = &MetaInfo{} // proceed without metadata\n}","preventionTips":["Avoid enabling XMP (imaging.meta.sources) unless you need it — it is the slowest and most error-prone source.","Run 'exiftool -X path/to/image.jpg' to preview the XMP packet before Hugo processes it.","Note this error uses %v, so it cannot be unwrapped with errors.Unwrap — match on the message prefix instead.","Test new image sources with a small batch before deploying to a large image set."],"tags":["hugo","imaging","metadata","xmp","iptc","corrupt-file"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}