{"record":{"id":"475cfe5a68011031","repo":"caddyserver/caddy","slug":"quality-too-low-must-be-d","errorCode":null,"errorMessage":"quality too low; must be >= %d","messagePattern":"quality too low; must be >= (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/encode/gzip/gzip.go","lineNumber":71,"sourceCode":"\tif err != nil {\n\t\treturn err\n\t}\n\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/","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/encode/gzip/gzip.go#L53-L89","documentation":"Validate-time error from the gzip encoder: the configured compression Level is below gzip.StatelessCompression (-2), the lowest level Go's compress/gzip accepts.","triggerScenarios":"{\"level\": -3} in the gzip encoder config, or a Caddyfile/JSON value that unmarshalates to a number < -2.","commonSituations":"Copy-pasting level values from other software (zstd/brotli use different ranges); negative numbers intended as 'no compression' set too low.","solutions":["Set level within [-2, 9] (gzip.StatelessCompression..gzip.BestCompression); omit it to use the default","Remember gzip levels are not zstd's speed names — use numbers only"],"exampleFix":"// before\n{\"level\": -3}\n// after\n{\"level\": 5}","handlingStrategy":"validation","validationCode":"// before applying config\nif lvl < -2 || lvl > 9 { return fmt.Errorf(\"gzip level out of range: %d\", lvl) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember gzip range is -2..9","Omit level to use Caddy's default"],"tags":["caddy","gzip","encode","validation","config"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}