caddyserver/caddy · error
encoder does not specify an Accept-Encoding value
Error message
encoder does not specify an Accept-Encoding value
What it means
Returned by Encode.addEncoding when an Encoding implementation's AcceptEncoding() returns an empty string. The Accept-Encoding token is used as the pool key and for client negotiation, so an empty value makes the encoder unusable.
Source
Thrown at modules/caddyhttp/encode/encode.go:206
}
}
err := next.ServeHTTP(w, r)
// If there was an error, disable encoding completely
// This prevents corruption when handle_errors processes the response
if err != nil {
if ew, ok := w.(*responseWriter); ok {
ew.disabled = true
}
}
return err
}
func (enc *Encode) addEncoding(e Encoding) error {
ae := e.AcceptEncoding()
if ae == "" {
return fmt.Errorf("encoder does not specify an Accept-Encoding value")
}
if _, ok := enc.writerPools[ae]; ok {
return fmt.Errorf("encoder already added: %s", ae)
}
if enc.writerPools == nil {
enc.writerPools = make(map[string]*sync.Pool)
}
enc.writerPools[ae] = &sync.Pool{
New: func() any {
return e.NewEncoder()
},
}
return nil
}
// openResponseWriter creates a new response writer that may (or may not)
// encode the response with encodingName. The returned response writer MUST
// be closed after the handler completes.View on GitHub (pinned to 50e54ee279)
Solutions
- Implement AcceptEncoding() to return a valid, unique token like "br" or "myzip"
- Register the token with IANA-style naming and keep it consistent with what clients send
Example fix
// before
func (E) AcceptEncoding() string { return "" }
// after
func (E) AcceptEncoding() string { return "myzip" } Defensive patterns
Strategy: type-guard
Type guard
// compile-time: your encoder satisfies the full contract var _ encode.Encoding = (*MyEncoding)(nil)
Prevention
- Always implement AcceptEncoding() with a unique token
- Unit-test plugin encoders through encode.Encode provisioning
When it happens
Trigger: Any custom encoder module whose AcceptEncoding() method returns "" being loaded during encode provisioning.
Common situations: Plugin authors implementing encode.Encoding but forgetting or stubbing AcceptEncoding().
Related errors
- adding encoding %s: %v
- encoder already added: %s
- loading encoder modules: %v
- encoding %s not enabled
- encoding %s is duplicated in prefer
AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15).
Data as JSON: /api/errors/eecb110f4130a1b8.
Report an issue: GitHub.