{"record":{"id":"bcfd0115890d288e","repo":"gohugoio/hugo","slug":"format-not-supported","errorCode":null,"errorMessage":"format not supported","messagePattern":"format not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/codec.go","lineNumber":222,"sourceCode":"\t\t\treturn img, nil\n\t\t}\n\t\tif rs, ok := r.(io.ReadSeeker); ok {\n\t\t\t// See issue 14288. Turns out it's not uncommon to e.g. name their PNG files with a WEBP extension.\n\t\t\t// With the old Go's webp decoder, this didn't fail (it looked for the file header),\n\t\t\t// but now some error has surfaced.\n\t\t\t// To reduce some noise, we try to reset and decode again using the standard library.\n\t\t\t_, err2 := rs.Seek(0, io.SeekStart)\n\t\t\tif err2 != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\timg, _, err2 = image.Decode(rs)\n\t\t\tif err2 == nil {\n\t\t\t\treturn img, nil\n\t\t\t}\n\t\t}\n\t\treturn nil, err\n\tdefault:\n\t\treturn nil, errors.New(\"format not supported\")\n\t}\n}\n\nfunc (d *Codec) Decode(r io.Reader) (image.Image, error) {\n\td.debugl.Log(\n\t\tlogg.StringFunc(\n\t\t\tfunc() string {\n\t\t\t\treturn \"Decoding image from unknown format\"\n\t\t\t},\n\t\t),\n\t)\n\trr := toPeekReader(r)\n\tformat, err := formatFromImage(rr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif format != 0 {\n\t\treturn d.DecodeFormat(format, rr)","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/codec.go#L204-L240","documentation":"`Codec.DecodeFormat` switches on the image `Format` enum to pick the right decoder. The default arm returns this error when the requested format is not one of JPEG, PNG, GIF, TIFF, BMP, AVIF, or WEBP. It means the Format value passed in has no registered decoder.","triggerScenarios":"A code path calling `DecodeFormat` with a zero-value or unsupported `Format` constant; an image whose detected format maps to no decoder; internal callers passing an uninitialized Format field.","commonSituations":"Adding a new image format constant without wiring a decoder; an image file with magic bytes that don't resolve to a known Format (so format stays 0 and is passed through); corruption in format detection.","solutions":["Confirm the source image is one of the supported formats (jpeg, png, gif, tiff, bmp, avif, webp).","If calling DecodeFormat programmatically, ensure the Format argument is set from formatFromImage detection, not left zero.","Convert the offending asset to a supported format with an external tool before feeding it to Hugo."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict source images to the supported formats (jpeg/png/gif/tiff/bmp/avif/webp).","Ensure programmatic callers derive Format via formatFromImage rather than leaving it zero."],"tags":["hugo","image-processing","codec","format-detection"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}