caddyserver/caddy · error
precompressor does not specify an Accept-Encoding value
Error message
precompressor does not specify an Accept-Encoding value
What it means
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.
Source
Thrown at modules/caddyhttp/fileserver/staticfiles.go:233
if abs, err := caddy.FastAbs(h); err == nil {
fsrv.Hide[i] = abs
}
}
}
// support precompressed sidecar files
mods, err := ctx.LoadModule(fsrv, "PrecompressedRaw")
if err != nil {
return fmt.Errorf("loading encoder modules: %v", err)
}
for modName, modIface := range mods.(map[string]any) {
p, ok := modIface.(encode.Precompressed)
if !ok {
return fmt.Errorf("module %s is not precompressor", modName)
}
ae := p.AcceptEncoding()
if ae == "" {
return fmt.Errorf("precompressor does not specify an Accept-Encoding value")
}
suffix := p.Suffix()
if suffix == "" {
return fmt.Errorf("precompressor does not specify a Suffix value")
}
if _, ok := fsrv.precompressors[ae]; ok {
return fmt.Errorf("precompressor already added: %s", ae)
}
if fsrv.precompressors == nil {
fsrv.precompressors = make(map[string]encode.Precompressed)
}
fsrv.precompressors[ae] = p
}
if fsrv.Browse != nil {
// check sort options
for idx, sortOption := range fsrv.Browse.SortOptions {
switch idx {View on GitHub (pinned to 50e54ee279)
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.
Example fix
// before
func (Foo) AcceptEncoding() string { return "" }
// after
func (Foo) AcceptEncoding() string { return "foo" } Defensive patterns
Strategy: validation
Validate before calling
// In your plugin's Validate(): reject empty Accept-Encoding early with a clear message
func (m *MyPrecompressor) Validate() error {
if m.AcceptEncoding() == "" {
return fmt.Errorf("accept_encoding must not be empty")
}
return nil
} Prevention
- 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.
When it happens
Trigger: A custom precompressor plugin whose AcceptEncoding() method returns "" (unimplemented stub, fallback value, or a configurable field left empty in config).
Common situations: 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.
Related errors
- precompressor does not specify a Suffix value
- module %s is not precompressor
- %s: invalid configuration: %v
- getting module named '%s': %v
- unknown try policy %s
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/e7b4dcebfba05b74.
Report an issue: GitHub.