influxdata/influxdb · error · Error::NonUtf8ContentEncodingHeader
invalid content-encoding header
Error message
invalid content-encoding header: {0} What it means
`Error::NonUtf8ContentEncodingHeader` is returned when the `Content-Encoding` header value cannot be converted to a string (wrapping `hyper::header::ToStrError`). Header values must contain only visible ASCII; invalid bytes make the header unreadable.
Solutions
- Inspect the outgoing request headers and ensure Content-Encoding contains only ASCII visible characters (e.g. "gzip", "identity")
- Fix or replace the HTTP client/proxy that emits malformed headers
- Remove the Content-Encoding header entirely if no encoding is actually applied
- Test with curl to confirm the server accepts the same call and isolate the faulty client
Example fix
// before
headers.insert("Content-Encoding", HeaderValue::from_bytes(b"gzip – chunked").unwrap());
// after
headers.insert("Content-Encoding", HeaderValue::from_static("gzip")); Defensive patterns
Strategy: validation
Validate before calling
function validAsciiHeader(v) { return typeof v === 'string' && /^[\x21-\x7E]+$/.test(v); } Prevention
- Only set headers from static ASCII constants
- Never interpolate free-form user text into header values
- Validate headers in HTTP middleware before dispatch
- Test with curl to rule out client-side header corruption
When it happens
Trigger: A client sends a `Content-Encoding` header containing non-ASCII/invalid bytes, e.g. raw UTF-8 characters, control characters, or a corrupted/malformed header produced by a custom HTTP client or proxy.
Common situations: Hand-rolled HTTP clients writing headers as raw bytes, misconfigured proxies mangling headers, or fuzz/ malicious clients sending non-ASCII header values.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- body content is not valid utf8
- invalid content-type header
- the mime type specified was not valid UTF8
- the mime type specified was not valid UTF8
- to str error
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/0449898e23f6dab6.
Report an issue: GitHub.
Appendix: source
Thrown at influxdb3_server/src/http.rs:204
impl From<ResourceAuthorizationError> for RoutingError {
fn from(e: ResourceAuthorizationError) -> Self {
Self::Authorization(e)
}
}
#[derive(Debug, Error)]
pub enum Error {
/// The requested path has no registered handler.
#[error("not found")]
NoHandler,
/// The request body content is not valid utf8.
#[error("body content is not valid utf8: {0}")]
NonUtf8Body(Utf8Error),
/// The `Content-Encoding` header is invalid and cannot be read.
#[error("invalid content-encoding header: {0}")]
NonUtf8ContentEncodingHeader(hyper::header::ToStrError),
/// The `Content-Type` header is invalid and cannot be read.
#[error("invalid content-type header: {0}")]
NonUtf8ContentTypeHeader(hyper::header::ToStrError),
/// The specified `Content-Encoding` is not acceptable.
#[error("unacceptable content-encoding: {0}")]
InvalidContentEncoding(String),
/// The specified `Content-Type` is not acceptable.
#[error("unacceptable content-type, expected: {expected}")]
InvalidContentType { expected: mime::Mime },
/// The client disconnected.
#[error("client disconnected")]
ClientHangup(Box<dyn std::error::Error + Send + Sync>),
View on GitHub (pinned to 06200ef96b)