{"id":"45cc5e281186e373","repo":"gohugoio/hugo","slug":"imaging-avif-quality-must-be-between-1-and-100-inc","errorCode":null,"errorMessage":"imaging.avif.quality must be between 1 and 100 inclusive, got %d","messagePattern":"imaging\\.avif\\.quality must be between 1 and 100 inclusive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":728,"sourceCode":"\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\n\t// Hint about what type of image this is.\n\t// Valid values are \"picture\", \"photo\", \"drawing\", \"icon\", or \"text\".\n\t// Default is \"photo\".","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L710-L746","documentation":"AvifConfig.init validates the effective AVIF quality after fallback resolution: an unset (0) value falls back to the global `imaging.quality`, then to 60, so any value reaching the check that is <1 or >100 was explicitly configured out of range. AVIF quality is a 1-100 scale where higher means better fidelity.","triggerScenarios":"Configuring `[imaging.avif] quality` (or the global `[imaging] quality`) with a negative number, a value over 100, or a fractional/percent-style value that decodes out of range. Fires at config load time.","commonSituations":"Using 0-255 or 0.0-1.0 quality scales from other encoders (e.g. cavif, sharp), setting quality = 0 in the global `imaging.quality` expecting \"lossless\" (0 means unset in the AVIF block but is invalid globally-propagated as-is only if negative/over-100), or typoing an extra digit like 850.","solutions":["Set `imaging.avif.quality` to an integer between 1 and 100 (default 60).","If you want lossless output, set `imaging.avif.compression = \"lossless\"` instead of an out-of-range quality.","Delete the key to inherit the global `imaging.quality` or the default of 60."],"exampleFix":"# before\n[imaging.avif]\nquality = 850\n# after\n[imaging.avif]\nquality = 85","handlingStrategy":"validation","validationCode":"if q := cfg.Imaging.AVIF.Quality; q < 1 || q > 100 {\n    return fmt.Errorf(\"avif quality %d out of range [1,100]\", q)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp or reject quality values outside 1–100 before writing config","Don't use 0 to mean 'default' — omit the key instead","Add a CI config-lint step that range-checks imaging.* values"],"tags":["hugo","config","imaging","avif"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}