{"record":{"id":"e7b4dcebfba05b74","repo":"caddyserver/caddy","slug":"precompressor-does-not-specify-an-accept-encoding","errorCode":null,"errorMessage":"precompressor does not specify an Accept-Encoding value","messagePattern":"precompressor does not specify an Accept-Encoding value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/caddyhttp/fileserver/staticfiles.go","lineNumber":233,"sourceCode":"\t\t\tif abs, err := caddy.FastAbs(h); err == nil {\n\t\t\t\tfsrv.Hide[i] = abs\n\t\t\t}\n\t\t}\n\t}\n\n\t// support precompressed sidecar files\n\tmods, err := ctx.LoadModule(fsrv, \"PrecompressedRaw\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"loading encoder modules: %v\", err)\n\t}\n\tfor modName, modIface := range mods.(map[string]any) {\n\t\tp, ok := modIface.(encode.Precompressed)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"module %s is not precompressor\", modName)\n\t\t}\n\t\tae := p.AcceptEncoding()\n\t\tif ae == \"\" {\n\t\t\treturn fmt.Errorf(\"precompressor does not specify an Accept-Encoding value\")\n\t\t}\n\t\tsuffix := p.Suffix()\n\t\tif suffix == \"\" {\n\t\t\treturn fmt.Errorf(\"precompressor does not specify a Suffix value\")\n\t\t}\n\t\tif _, ok := fsrv.precompressors[ae]; ok {\n\t\t\treturn fmt.Errorf(\"precompressor already added: %s\", ae)\n\t\t}\n\t\tif fsrv.precompressors == nil {\n\t\t\tfsrv.precompressors = make(map[string]encode.Precompressed)\n\t\t}\n\t\tfsrv.precompressors[ae] = p\n\t}\n\n\tif fsrv.Browse != nil {\n\t\t// check sort options\n\t\tfor idx, sortOption := range fsrv.Browse.SortOptions {\n\t\t\tswitch idx {","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/fileserver/staticfiles.go#L215-L251","documentation":"Returned in FileServer.Provision when a precompressor module's AcceptEncoding() returns an empty string. The Accept-Encoding value is the key used to match client requests to the sidecar file, so an empty value makes the precompressor unusable and provisioning aborts.","triggerScenarios":"A custom precompressor plugin whose AcceptEncoding() method returns \"\" (unimplemented stub, fallback value, or a configurable field left empty in config).","commonSituations":"Bare-bones plugin scaffolding where methods return zero values; a plugin that reads its Accept-Encoding from a config field the user did not set; copy-paste plugin templates with TODO stubs.","solutions":["Make AcceptEncoding() return a non-empty, valid token such as \"zstd\", \"gzip\", or \"br\".","If the value comes from user config, validate it in the module's own Provision/Validate and fail early with a clear message.","Set the missing config field in your Caddyfile/JSON for the plugin."],"exampleFix":"// before\nfunc (Foo) AcceptEncoding() string { return \"\" }\n// after\nfunc (Foo) AcceptEncoding() string { return \"foo\" }","handlingStrategy":"validation","validationCode":"// In your plugin's Validate(): reject empty Accept-Encoding early with a clear message\nfunc (m *MyPrecompressor) Validate() error {\n    if m.AcceptEncoding() == \"\" {\n        return fmt.Errorf(\"accept_encoding must not be empty\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave stub methods returning zero values in shipped plugins.","Add unit tests that instantiate the module and assert non-empty AcceptEncoding().","Fill every plugin config field in examples so users copy complete configs."],"tags":["caddy","fileserver","precompressed","module-system","validation"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}