{"id":"c9132c201bb1fa23","repo":"gohugoio/hugo","slug":"received-invalid-image-dimensions-dx-d-stride-d","errorCode":null,"errorMessage":"received invalid image dimensions: %dx%d stride %d","messagePattern":"received invalid image dimensions: (.+?)x(.+?) stride (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/warpc/avif.go","lineNumber":132,"sourceCode":"\t\t\tRequestKinds:  []string{MessageKindJSON, MessageKindBlob},\n\t\t\tResponseKinds: []string{MessageKindJSON, MessageKindBlob},\n\t\t},\n\n\t\tData: AvifInput{\n\t\t\tSource:      source,\n\t\t\tDestination: &destination,\n\t\t\tOptions:     map[string]any{},\n\t\t},\n\t}\n\n\tout, err := dd.Execute(context.Background(), message)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tw, h, stride, depth := out.Data.Params.Width, out.Data.Params.Height, out.Data.Params.Stride, out.Data.Params.Depth\n\tif w == 0 || h == 0 || stride == 0 {\n\t\treturn nil, fmt.Errorf(\"received invalid image dimensions: %dx%d stride %d\", w, h, stride)\n\t}\n\n\t// For 10+ bit HDR images, the C code returns 16-bit RGBA data.\n\tisHDR := depth > 8\n\n\t// libavif returns 16-bit data in native (little-endian) byte order,\n\t// but Go's NRGBA64 expects big-endian. Swap bytes for HDR images.\n\tif isHDR {\n\t\tpix := destination.Bytes()\n\t\tfor i := 0; i < len(pix); i += 2 {\n\t\t\tpix[i], pix[i+1] = pix[i+1], pix[i]\n\t\t}\n\t}\n\n\tif len(out.Data.Params.FrameDurations) > 0 {\n\t\timg := &AnimatedImage{\n\t\t\tframeDurations:          out.Data.Params.FrameDurations,\n\t\t\tloopCount:               avifLoopCountToGo(out.Data.Params.LoopCount),","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/internal/warpc/avif.go#L114-L150","documentation":"Raised in Hugo's WASM-based AVIF decoder (internal/warpc/avif.go:131) after the sandboxed libavif module returns decode results. The returned header params (width, height, stride) are sanity-checked; a zero in any of them means the decoded pixel geometry is unusable, so Hugo fails fast rather than constructing an invalid image.","triggerScenarios":"Processing an .avif image through Hugo's image pipeline (resources.Get + .Resize/.Process, or any decode path hitting AvifCodec.Decode) where the WASM libavif module reports width, height, or stride of 0 in its JSON response.","commonSituations":"Corrupted or truncated AVIF files (bad download, git-lfs pointer file with .avif extension); files that are not actually AVIF; malformed AVIF produced by buggy encoders; rarely, a mismatch between the Hugo binary and its embedded WASM module after a broken build.","solutions":["Verify the source file is a valid AVIF: run `avifdec` or `ffprobe` on it, or open it in a browser.","Re-export/re-encode the image from the original source (e.g. `avifenc input.png out.avif`).","Check the file isn't a git-lfs pointer or truncated asset (compare file size to the original).","If all AVIFs fail after an upgrade, reinstall the official Hugo extended binary."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"cfg, _, err := image.DecodeConfig(reader)\nif err != nil || cfg.Width <= 0 || cfg.Height <= 0 || cfg.Width*cfg.Height > maxPixels {\n    return fmt.Errorf(\"reject image %dx%d\", cfg.Width, cfg.Height)\n}","typeGuard":null,"tryCatchPattern":"img, err := decodeAVIF(buf)\nif err != nil {\n    // corrupt/hostile file — skip asset, log source path, do not retry\n    return fmt.Errorf(\"avif decode %s: %w\", path, err)\n}","preventionTips":["Pre-check image dimensions with image.DecodeConfig before full decode","Enforce a max-pixel budget on user-supplied images","Treat decode errors as per-asset failures: report the source file and continue the build"],"tags":["hugo","avif","image-processing","wasm","warpc","decode"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}