{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/internal/warpc/avif.go#L114-L150","documentation":"Thrown after a WASM-based AVIF decode when the returned Width, Height, or Stride from the avif codec is zero. The decoder reported success (dd.Execute returned no error) but the response params carry zero dimensions, which is unusable.","triggerScenarios":"An AVIF file is fed to AvifCodec.Decode; the WASM decoder executes successfully but the response's Width/Height/Stride fields are all 0. The check at avif.go:131 trips immediately, before any pixel buffer is constructed.","commonSituations":"Corrupt or truncated AVIF; an HEIF container the libavif decoder couldn't parse; an empty file; an unsupported AVIF profile (e.g., AVIF-J2K sequence); a bug or version mismatch in the bundled libavif WASM.","solutions":["Re-export the AVIF from a known-good source (e.g., avifenc).","Try decoding a different AVIF to isolate whether the issue is the file or the decoder.","Check the libavif/aom/dav1d versions bundled with your Hugo release for known issues against this image.","Re-encode the failing image with a standard AVIF tool and retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before decode, confirm the file is non-empty and looks like an AVIF/HEIF\n// box (ftyp brand).\nhdr := make([]byte, 12)\nif _, err := io.ReadFull(r, hdr); err != nil {\n    return fmt.Errorf(\"cannot read AVIF header: %w\", err)\n}\nif len(hdr) < 12 || string(hdr[8:12]) != \"ftyp\" {\n    return fmt.Errorf(\"not an AVIF/HEIF file (missing ftyp box)\")\n}\n// rewind r before handing to Decode","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate AVIFs at ingestion: non-empty and ftyp box present.","Maintain a known-good test AVIF for decoder regression checks.","Track the bundled libavif/aom/dav1d versions in your Hugo release and watch for upstream fixes."],"tags":["avif","image","warp","decode"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}