{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/meta/meta.go#L287-L323","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Find the named file in the log and strip or rewrite its metadata (`exiftool -all= file.jpg`), then rebuild.","Confirm the file is intact and its extension matches its real format.","Upgrade Hugo to pick up imagemeta parser fixes; report reproducible panics upstream with the image attached."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"md, err := decodeMetadata(r)\nif err != nil {\n    log.Printf(\"metadata decode failed for %s: %v\", name, err)\n    // treat image as having no metadata; do not abort processing\n}","preventionTips":["Verify image files are not truncated (compare byte size, run `identify`/`exiftool` in a pre-commit check)","Strip or normalize metadata with exiftool for images from untrusted sources","Guard template metadata access with existence checks before dereferencing fields"],"tags":["hugo","images","metadata","exif","xmp","iptc","panic-recovery"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}