{"record":{"id":"3c1cfa0c54ce5287","repo":"influxdata/influxdb","slug":"invalid-mime-type-0","errorCode":null,"errorMessage":"invalid mime type ({0})","messagePattern":"invalid mime type \\((.+?)\\)","errorType":"http","errorClass":"Error::InvalidMimeType","httpStatus":null,"severity":"error","filePath":"core/iox_v1_query_api/src/error.rs","lineNumber":25,"sourceCode":"/// Error type for the v1 API\n///\n/// This is used to catch errors that occur during the streaming process.\n/// [`anyhow::Error`] is used as a catch-all because if anything fails during\n/// that process it will result in a 500 INTERNAL ERROR.\n#[derive(Debug, thiserror::Error)]\n#[error(\"unexpected query error: {0}\")]\npub struct QueryError(#[from] pub anyhow::Error);\n\n#[derive(Debug, Error)]\npub enum Error {\n    /// The requested path has no registered handler.\n    #[error(\"not found: {0}\")]\n    NoHandler(String),\n\n    #[error(\"authorization failure: {0}\")]\n    AuthorizationFailure(String),\n\n    #[error(\"invalid mime type ({0})\")]\n    InvalidMimeType(String),\n\n    /// Missing parameters for query\n    #[error(\"missing query parameters 'db' and 'q'\")]\n    MissingQueryParams,\n\n    #[error(\"error decoding multipart file upload: {0}\")]\n    MultipartFile(String),\n\n    #[error(\"Invalid UTF8: {message} {error}\")]\n    Utf8 {\n        message: &'static str,\n        error: String,\n    },\n\n    /// Serde decode error\n    #[error(\"error decoding params from url: {0}\")]\n    SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_v1_query_api/src/error.rs#L7-L43","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Remove conflicting charset/parameters from the header if the server fails to parse it.","Check client library defaults and override the content type explicitly."],"exampleFix":"// before\nclient.post(\"/query\").body(\"SELECT 1\").header(\"content-type\", \"text/plain\")\n// after\nclient.post(\"/query\").body(\"SELECT 1\").header(\"content-type\", \"application/vnd.influxql\")","handlingStrategy":"validation","validationCode":"const ALLOWED: &[&str] = &[\"application/vnd.influxql\", \"application/x-www-form-urlencoded\", \"application/json\"];\nfn content_type_ok(ct: &str) -> bool {\n    ALLOWED.iter().any(|a| ct.starts_with(a))\n}","typeGuard":"fn is_invalid_mime(e: &iox_v1_query_api::Error) -> Option<&str> {\n    match e { iox_v1_query_api::Error::InvalidMimeType(m) => Some(m), _ => None }\n}","tryCatchPattern":"if !content_type_ok(&ct) {\n    request = request.header(\"content-type\", \"application/vnd.influxql\");\n}\nlet resp = request.body(sql).send().await?;","preventionTips":["Always set Content-Type explicitly on POST requests; never rely on client defaults.","Keep a single request-builder helper per endpoint that pins the correct content type.","Avoid appending charset/parameters to the header unless documented as supported."],"tags":["rust","http-api","content-type","mime","thiserror"],"backgroundTag":"invalid-argument-format","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}