{"record":{"id":"a235f571f7f11ed2","repo":"caddyserver/caddy","slug":"quality-too-high-must-be-d","errorCode":null,"errorMessage":"quality too high; must be <= %d","messagePattern":"quality too high; must be <= (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/encode/gzip/gzip.go","lineNumber":74,"sourceCode":"\tg.Level = level\n\treturn nil\n}\n\n// Provision provisions g's configuration.\nfunc (g *Gzip) Provision(ctx caddy.Context) error {\n\tif g.Level == 0 {\n\t\tg.Level = defaultGzipLevel\n\t}\n\treturn nil\n}\n\n// Validate validates g's configuration.\nfunc (g Gzip) Validate() error {\n\tif g.Level < gzip.StatelessCompression {\n\t\treturn fmt.Errorf(\"quality too low; must be >= %d\", gzip.StatelessCompression)\n\t}\n\tif g.Level > gzip.BestCompression {\n\t\treturn fmt.Errorf(\"quality too high; must be <= %d\", gzip.BestCompression)\n\t}\n\treturn nil\n}\n\n// AcceptEncoding returns the name of the encoding as\n// used in the Accept-Encoding request headers.\nfunc (Gzip) AcceptEncoding() string { return \"gzip\" }\n\n// NewEncoder returns a new gzip writer.\nfunc (g Gzip) NewEncoder() encode.Encoder {\n\twriter, _ := gzip.NewWriterLevel(nil, g.Level)\n\treturn writer\n}\n\n// Informed from http://blog.klauspost.com/gzip-performance-for-go-webservers/\nvar defaultGzipLevel = 5\n\n// Interface guards","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/encode/gzip/gzip.go#L56-L92","documentation":"Validate-time error from the gzip encoder: Level exceeds gzip.BestCompression (9). Go's compress/gzip only accepts levels -2 through 9.","triggerScenarios":"{\"level\": 10} or higher in the gzip encoder config — often carried over from brotli (0-11) or zstd conventions.","commonSituations":"Porting compression settings from nginx (gzip levels up to 9 are fine but brotli configs use 11) or other servers with wider ranges.","solutions":["Set level to at most 9; typical values are 5-9","Omit level to accept the default (defaultGzipLevel)"],"exampleFix":"// before\n{\"level\": 11}\n// after\n{\"level\": 9}","handlingStrategy":"validation","validationCode":"if lvl > 9 { lvl = 9 } // clamp, or reject in config validation","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't reuse brotli/zstd level numbers for gzip","caddy validate the config before deploy"],"tags":["caddy","gzip","encode","validation","config"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}