{"record":{"id":"d00fae187d09a625","repo":"gohugoio/hugo","slug":"invalid-jpeg-config-w","errorCode":null,"errorMessage":"invalid jpeg config: %w","messagePattern":"invalid jpeg config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":568,"sourceCode":"\t\treturn cfg.Avif.Hint\n\t}\n\treturn \"\"\n}\n\nvar validMetaSources = map[string]bool{\n\t\"exif\": true,\n\t\"iptc\": true,\n\t\"xmp\":  true,\n}\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\"","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L550-L586","documentation":"Returned by ImagingConfig.init when JpegConfig.init fails, wrapping the jpeg-specific error. JpegConfig.init validates that imaging.jpeg.quality (falling back to imaging.quality then 75) is between 1 and 100 inclusive. The %w preserves the underlying message ('imaging.jpeg.quality must be between 1 and 100 inclusive, got N').","triggerScenarios":"Setting [imaging.jpeg] quality = 0 or quality = 150 (out of 1-100) in hugo.toml, or imaging.quality = 200 which propagates as the jpeg fallback. Fails at startup during config decode.","commonSituations":"A quality value of 0 (mistakenly thinking 0 means default), a value greater than 100, or a negative value; misreading the 1-100 inclusive range.","solutions":["Set imaging.jpeg.quality to an integer between 1 and 100 inclusive.","If using the deprecated imaging.quality, ensure it is in 1-100.","Omit quality to accept the default of 75."],"exampleFix":"// before\n[imaging.jpeg]\nquality = 0\n\n// after\n[imaging.jpeg]\nquality = 75","handlingStrategy":"validation","validationCode":"func validJpegQuality(q int) bool { return q >= 1 && q <= 100 }","typeGuard":"func isValidJpegQuality(q int) bool { return q >= 1 && q <= 100 }","tryCatchPattern":"if err := cfg.Imaging.init(); err != nil {\n    if strings.Contains(err.Error(), \"invalid jpeg config\") { /* fix imaging.jpeg.quality */ }\n}","preventionTips":["Set imaging.jpeg.quality between 1 and 100 inclusive.","Omit it to accept the default of 75.","If using deprecated imaging.quality, keep it in 1-100."],"tags":["image-processing","config","jpeg","quality","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}