influxdata/influxdb · error · Error

the mime type specified was not valid UTF8

Error message

the mime type specified was not valid UTF8: {0}

What it means

Raised when an HTTP request's Content-Type (or similar) header value cannot be decoded as UTF-8. The header bytes are converted via String::from_utf8 and the resulting FromUtf8Error is wrapped by #[from]. It means the client sent header bytes that are not valid UTF-8, which the server refuses to interpret.

Solutions

  1. Send the Content-Type header as ASCII/UTF-8, e.g. 'text/plain' or 'application/json'
  2. Inspect the raw request bytes (tcpdump/wireshark) for non-ASCII bytes in headers
  3. Update or fix the client library that builds the request headers
  4. Sanitize header values before sending: only printable ASCII is allowed

Example fix

// before
req.header("Content-Type", "text/plain; charset=ISO-8859-1".encode("ISO-8859-1"))
// after
req.header("Content-Type", "text/plain; charset=utf-8")
Defensive patterns

Strategy: type-guard

Validate before calling

const ct = request.headers.get("content-type") ?? "";
if (!/^\x20-\x7E*$/.test(ct)) throw new Error("Content-Type must be printable ASCII");

Type guard

function isAsciiHeader(v) { return typeof v === "string" && /^[\x20-\x7E]*$/.test(v); }

Try / catch

try { await send(req); } catch (e) {
  if (String(e).includes("not valid UTF8")) {
    // re-encode all headers to ASCII and resend
  }
}

Prevention

When it happens

Trigger: Sending a Content-Type header containing raw non-UTF-8 bytes (e.g. Latin-1 encoded charset strings) to a write or query endpoint.

Common situations: Custom HTTP clients or old SDKs that encode header values in a legacy codepage; corrupted/mangled requests from misconfigured middleware.

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/aa286d6d5696aac7. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_server/src/http.rs:279

    ServingHttp(#[from] hyper::Error),

    /// Missing parameters for query
    #[error("missing query parameters 'db'")]
    MissingDeleteDatabaseParams,

    /// Missing parameters for query
    #[error("missing query parameters 'db' and 'q'")]
    MissingQueryParams,

    /// Missing the `q` parameter in the v1 /query API
    #[error("missing query parameter 'q'")]
    MissingQueryV1Params,

    /// MIssing parameters for write
    #[error("missing query parameter 'db'")]
    MissingWriteParams,

    #[error("the mime type specified was not valid UTF8: {0}")]
    NonUtf8MimeType(#[from] FromUtf8Error),

    /// Serde decode error
    #[error("serde error: {0}")]
    SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),

    /// Arrow error
    #[error("arrow error: {0}")]
    Arrow(#[from] arrow::error::ArrowError),

    /// Hyper error
    #[error("hyper http error: {0}")]
    Hyper(#[from] hyper::http::Error),

    /// WriteBuffer error
    #[error("write buffer error: {0}")]
    WriteBuffer(#[from] influxdb3_write::write_buffer::Error),

View on GitHub (pinned to 06200ef96b)