{"record":{"id":"b534f25d3f5e4046","repo":"gohugoio/hugo","slug":"imaging-avif-compression-must-be-one-of-lossy-or-l","errorCode":null,"errorMessage":"imaging.avif.compression must be one of lossy or lossless, got %q","messagePattern":"imaging\\.avif\\.compression must be one of lossy or lossless, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":725,"sourceCode":"\tif c.Compression == \"\" {\n\t\tc.Compression = defaultCompression\n\t}\n\tif c.Quality == 0 {\n\t\tc.Quality = 60\n\t}\n\n\tc.Hint = strings.ToLower(c.Hint)\n\tc.Compression = strings.ToLower(c.Compression)\n\n\tif c.Hint != \"\" && !hints[c.Hint] {\n\t\treturn fmt.Errorf(\"imaging.avif.hint must be one of picture, photo, drawing, icon, or text, got %q\", c.Hint)\n\t}\n\tif c.EncoderSpeed < 1 || c.EncoderSpeed > 10 {\n\t\treturn fmt.Errorf(\"imaging.avif.encoderSpeed must be between 1 and 10, got %d\", c.EncoderSpeed)\n\t}\n\n\tif c.Compression != \"\" && !compressionMethods[c.Compression] {\n\t\treturn fmt.Errorf(\"imaging.avif.compression must be one of lossy or lossless, got %q\", c.Compression)\n\t}\n\tif c.Quality < 1 || c.Quality > 100 {\n\t\treturn fmt.Errorf(\"imaging.avif.quality must be between 1 and 100 inclusive, got %d\", c.Quality)\n\t}\n\n\treturn nil\n}\n\n// WebpConfig holds WebP-specific encoding configuration.\ntype WebpConfig struct {\n\t// Quality setting (1-100). Falls back to the global imaging.quality if unset.\n\t// Only relevant for lossy encoding.\n\tQuality int\n\n\t// Compression method to use.\n\t// One of \"lossy\" or \"lossless\".\n\tCompression string\n","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L707-L743","documentation":"Validates the AVIF compression method after lowercasing and fallback. Must be either 'lossy' or 'lossless' (defined in the compressionMethods map). If unset, it inherits the global compression, then defaults to 'lossy'. Only checked when compression is non-empty after resolution.","triggerScenarios":"Setting imaging.avif.compression (or the global imaging.compression) to any string other than lossy or lossless. Case-insensitive after normalization.","commonSituations":"Typing 'losless' (missing an s), 'loss-less', 'high', or 'max'; confusing compression with quality.","solutions":["Set imaging.avif.compression to either 'lossy' or 'lossless'.","Omit the key to use the default 'lossy', which is best for photographs.","Use 'lossless' only for images where pixel-perfect reproduction matters (screenshots, diagrams) — it produces significantly larger files."],"exampleFix":"# before (hugo.toml)\n[imaging.avif]\ncompression = \"losless\"\n\n# after\n[imaging.avif]\ncompression = \"lossless\"","handlingStrategy":"validation","validationCode":"// Validate AVIF compression\nfunc validateAvifCompression(c string) error {\n    c = strings.ToLower(c)\n    if c != \"\" && c != \"lossy\" && c != \"lossless\" {\n        return fmt.Errorf(\"invalid avif compression %q; valid: lossy, lossless\", c)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 'lossy' for photographs (dramatically smaller files).","Use 'lossless' only for screenshots, diagrams, or logos with sharp edges.","Double-check spelling: 'lossless' has two s's in each half."],"tags":["hugo","imaging","avif","config-validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}