{"record":{"id":"bacc5e05d815c6b3","repo":"gohugoio/hugo","slug":"imaging-quality-must-be-between-1-and-100-inclusiv","errorCode":null,"errorMessage":"imaging.quality must be between 1 and 100 inclusive, got %d","messagePattern":"imaging\\.quality must be between 1 and 100 inclusive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":577,"sourceCode":"}\n\nfunc (cfg *ImagingConfig) init() error {\n\tcfg.BgColor = strings.ToLower(strings.TrimPrefix(cfg.BgColor, \"#\"))\n\tcfg.Anchor = strings.ToLower(cfg.Anchor)\n\tcfg.ResampleFilter = strings.ToLower(cfg.ResampleFilter)\n\tcfg.Hint = strings.ToLower(cfg.Hint)\n\tcfg.Compression = strings.ToLower(cfg.Compression)\n\tif err := cfg.Jpeg.init(cfg); err != nil {\n\t\treturn fmt.Errorf(\"invalid jpeg config: %w\", err)\n\t}\n\tif err := cfg.Webp.init(cfg); err != nil {\n\t\treturn fmt.Errorf(\"invalid webp config: %w\", err)\n\t}\n\tif err := cfg.Avif.init(cfg); err != nil {\n\t\treturn fmt.Errorf(\"invalid avif config: %w\", err)\n\t}\n\tif cfg.Quality < 0 || cfg.Quality > 100 {\n\t\treturn fmt.Errorf(\"imaging.quality must be between 1 and 100 inclusive, got %d\", cfg.Quality)\n\t}\n\n\tif cfg.Anchor == \"\" {\n\t\tcfg.Anchor = smartCropIdentifier\n\t}\n\n\tif strings.TrimSpace(cfg.Exif.IncludeFields) == \"\" && strings.TrimSpace(cfg.Exif.ExcludeFields) == \"\" {\n\t\t// Don't change this for no good reason. Please don't.\n\t\tcfg.Exif.ExcludeFields = \"GPS|Exif|Exposure[M|P|B]|Contrast|Resolution|Sharp|JPEG|Metering|Sensing|Saturation|ColorSpace|Flash|WhiteBalance\"\n\t}\n\n\tif len(cfg.Meta.Fields) == 0 {\n\t\t// Default: include all fields except technical metadata.\n\t\t// Don't change this for no good reason. Please don't.\n\t\tcfg.Meta.Fields = []string{\n\t\t\t\"! *{GPS,Exif,Exposure[MPB],Contrast,Resolution,Sharp,JPEG,Metering,Sensing,Saturation,ColorSpace,Flash,WhiteBalance}*\",\n\t\t}\n\t}","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L559-L595","documentation":"Validates the global imaging.quality field. The code checks cfg.Quality < 0 || cfg.Quality > 100, so a value of 0 is allowed (meaning 'unset — use per-format defaults'). Any negative value or value above 100 is rejected. The message text says 'between 1 and 100' because 0 is the sentinel for 'not configured' rather than a meaningful quality.","triggerScenarios":"Setting imaging.quality in hugo.toml to a negative number or a value above 100. The zero value (Go int default) does NOT trigger this error because 0 means 'inherit per-format defaults.'","commonSituations":"Setting quality to 100+ thinking higher is always better; a YAML/TOML parser interpreting a quoted \"100\" plus a stray digit; importing a config from a tool that uses 0-1000 quality scales.","solutions":["Set imaging.quality to a value between 1 and 100 in hugo.toml, or omit it entirely to use per-format defaults (JPEG 75, WebP 75, AVIF 60).","If you want maximum quality, use 100 — not a value above it.","Verify there are no stray characters or encoding issues in the TOML/YAML value."],"exampleFix":"# before (hugo.toml)\n[imaging]\nquality = 120\n\n# after\n[imaging]\nquality = 100","handlingStrategy":"validation","validationCode":"// Validate global imaging quality\nfunc validateGlobalQuality(q int) error {\n    // 0 is allowed (means 'use per-format defaults'); 1-100 is explicit.\n    if q < 0 || q > 100 {\n        return fmt.Errorf(\"imaging.quality must be 0 or 1-100, got %d\", q)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit imaging.quality entirely if you want per-format defaults — JPEG 75, WebP 75, AVIF 60.","Never set quality above 100; the maximum meaningful value is 100.","Remember that quality 0 is not an error here — it means 'unset'."],"tags":["hugo","imaging","config-validation","quality"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}