influxdata/influxdb · error · Error
invalid mime type ( )
Error message
invalid mime type ({0}) What it means
Error::InvalidMimeType in influxdb3_types::http is thrown when a supplied MIME/media type string cannot be parsed as a valid mime type. The offending string is included in the message. It guards HTTP request/response handling where a known Content-Type must be resolved.
Solutions
- Fix the media type string to a valid value such as "application/json" or "text/csv"
- Strip malformed parameters and re-send a canonical Content-Type header
- Inspect the value in parentheses in the message to find which header value was rejected
Example fix
// before let mime: Mime = "text/".parse()?; // invalid // after let mime: Mime = "application/json".parse()?;
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_mime(s: &str) -> bool {
s.parse::<mime::Mime>().is_ok()
} Type guard
fn as_valid_mime(s: &str) -> Option<mime::Mime> {
s.parse::<mime::Mime>().ok()
} Try / catch
match result {
Ok(v) => v,
Err(e) if e.to_string().contains("invalid mime type") => /* reject request with 400 */,
Err(e) => return Err(e),
} Prevention
- Use a mime parsing library instead of ad-hoc string handling
- Send canonical Content-Type values from clients
- Test header handling with odd client values
When it happens
Trigger: Passing an unparsable Content-Type or Accept string to the HTTP type conversion/parsing code in influxdb3_types::http, e.g. malformed values like "text/" or "foo;bar=".
Common situations: Manually constructed headers, proxies or clients sending unusual Content-Type values, typo'd media types in configuration, tests hardcoding fake mime strings.
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
- error reading field from body
- invalid mime type ( )
- missing bucket value
- the mime type specified was not valid UTF8
- unacceptable content-type, expected
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/ea667d65bcfa8801.
Report an issue: GitHub.
Appendix: source
Thrown at influxdb3_types/src/http.rs:60
impl<'a> serde::Deserialize<'a> for HardDeletionTime {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'a>,
{
let s = String::deserialize(deserializer)?;
match s.as_str() {
"never" => Ok(Self::Never),
"now" => Ok(Self::Now),
"default" => Ok(Self::Default),
timestamp => Ok(Self::Timestamp(timestamp.to_string())),
}
}
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid mime type ({0})")]
InvalidMimeType(String),
#[error("the mime type specified was not valid UTF8: {0}")]
NonUtf8MimeType(#[from] std::string::FromUtf8Error),
#[error(transparent)]
Unexpected(#[from] anyhow::Error),
}
impl From<&Error> for hyper::StatusCode {
fn from(value: &Error) -> Self {
match value {
Error::InvalidMimeType(_) | Error::NonUtf8MimeType(_) => Self::BAD_REQUEST,
Error::Unexpected(_) => Self::INTERNAL_SERVER_ERROR,
}
}
}
View on GitHub (pinned to 06200ef96b)