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

  1. Inspect the outgoing request headers and ensure Content-Encoding contains only ASCII visible characters (e.g. "gzip", "identity")
  2. Fix or replace the HTTP client/proxy that emits malformed headers
  3. Remove the Content-Encoding header entirely if no encoding is actually applied
  4. 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

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


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)