{"record":{"id":"dc7e76afc932fa0c","repo":"gohugoio/hugo","slug":"failed-to-decode-image-s-dc7e76","errorCode":null,"errorMessage":"failed to decode image: %s","messagePattern":"failed to decode image: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/overlay.go","lineNumber":34,"sourceCode":"import (\n\t\"fmt\"\n\t\"image\"\n\t\"image/draw\"\n\n\t\"github.com/gohugoio/gift\"\n)\n\nvar _ gift.Filter = (*overlayFilter)(nil)\n\ntype overlayFilter struct {\n\tsrc  ImageSource\n\tx, y int\n}\n\nfunc (f overlayFilter) Draw(dst draw.Image, src image.Image, options *gift.Options) {\n\toverlaySrc, err := f.src.DecodeImage()\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"failed to decode image: %s\", err))\n\t}\n\n\tgift.New().Draw(dst, src)\n\tgift.New().DrawAt(dst, overlaySrc, image.Pt(f.x, f.y), gift.OverOperator)\n}\n\nfunc (f overlayFilter) Bounds(srcBounds image.Rectangle) image.Rectangle {\n\treturn image.Rect(0, 0, srcBounds.Dx(), srcBounds.Dy())\n}\n","sourceCodeStart":16,"sourceCodeEnd":44,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/overlay.go#L16-L44","documentation":"Thrown by the overlay filter's Draw when the overlay source image cannot be decoded (overlay.go:32-35). Identical mechanism to the mask decode error: DecodeImage returns an error and the filter panics with the underlying message.","triggerScenarios":"Calling images.Overlay with a src resource that fails to decode — corrupt bytes, unsupported format, empty file, or non-image content masquerading as an image resource.","commonSituations":"Watermark/logo resource is missing or corrupt; remote overlay fetch returned an error page; format unsupported by the image decoder.","solutions":["Confirm the overlay resource is a valid decodable image.","Validate the resource loads before composing the overlay filter.","Replace corrupt or wrong-format overlay assets."],"exampleFix":"// before\n{{ $logo := resources.GetRemote \"https://example.com/logo\" }}\n{{ $filters = $filters | append (images.Overlay $logo 0 0) }}\n// after\n{{ $logo := resources.Get \"brand/logo.png\" }}\n{{ $filters = $filters | append (images.Overlay $logo 0 0) }}","handlingStrategy":"validation","validationCode":"{{ with $overlay }}\n  {{ if reflect.IsImageResource . }}\n    {{ $filters = $filters | append (images.Overlay . 0 0) }}\n  {{ else }}\n    {{ errorf \"overlay is not a processable image\" }}\n  {{ end }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm overlay assets are valid raster images.","Validate remote overlays loaded successfully before composing.","Cache overlay assets locally to avoid repeated decode failures."],"tags":["image-filter","overlay","decode","resource-loading","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}