influxdata/influxdb · error · Error::InvalidMimeType

invalid mime type ( )

Error message

invalid mime type ({0})

What it means

`Error::InvalidMimeType(String)` is thrown when a request carries a Content-Type (or similar) header the v1 query API cannot handle. The unsupported or malformed media type value is embedded in the message.

Solutions

  1. Set the Content-Type header to one the endpoint accepts (e.g. `application/vnd.influxql` for raw InfluxQL, or `application/x-www-form-urlencoded` for form params).
  2. Remove conflicting charset/parameters from the header if the server fails to parse it.
  3. Check client library defaults and override the content type explicitly.

Example fix

// before
client.post("/query").body("SELECT 1").header("content-type", "text/plain")
// after
client.post("/query").body("SELECT 1").header("content-type", "application/vnd.influxql")
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED: &[&str] = &["application/vnd.influxql", "application/x-www-form-urlencoded", "application/json"];
fn content_type_ok(ct: &str) -> bool {
    ALLOWED.iter().any(|a| ct.starts_with(a))
}

Type guard

fn is_invalid_mime(e: &iox_v1_query_api::Error) -> Option<&str> {
    match e { iox_v1_query_api::Error::InvalidMimeType(m) => Some(m), _ => None }
}

Try / catch

if !content_type_ok(&ct) {
    request = request.header("content-type", "application/vnd.influxql");
}
let resp = request.body(sql).send().await?;

Prevention

When it happens

Trigger: POSTing query bodies with a Content-Type other than the supported ones (e.g. `application/x-www-form-urlencoded` vs `application/vnd.influxql` or JSON variants), or a malformed header value.

Common situations: HTTP clients defaulting to `text/plain` or omitting Content-Type on POST /query, middleware rewriting the header, or using a client library that encodes the body differently than its header claims.

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

Appendix: source

Thrown at core/iox_v1_query_api/src/error.rs:25

/// Error type for the v1 API
///
/// This is used to catch errors that occur during the streaming process.
/// [`anyhow::Error`] is used as a catch-all because if anything fails during
/// that process it will result in a 500 INTERNAL ERROR.
#[derive(Debug, thiserror::Error)]
#[error("unexpected query error: {0}")]
pub struct QueryError(#[from] pub anyhow::Error);

#[derive(Debug, Error)]
pub enum Error {
    /// The requested path has no registered handler.
    #[error("not found: {0}")]
    NoHandler(String),

    #[error("authorization failure: {0}")]
    AuthorizationFailure(String),

    #[error("invalid mime type ({0})")]
    InvalidMimeType(String),

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

    #[error("error decoding multipart file upload: {0}")]
    MultipartFile(String),

    #[error("Invalid UTF8: {message} {error}")]
    Utf8 {
        message: &'static str,
        error: String,
    },

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

View on GitHub (pinned to 06200ef96b)