{"record":{"id":"dd60f1d051ba30e6","repo":"influxdata/influxdb","slug":"invalid-utf8-message-error","errorCode":null,"errorMessage":"Invalid UTF8: {message} {error}","messagePattern":"Invalid UTF8: (.+?) (.+?)","errorType":"http","errorClass":"Error::Utf8","httpStatus":null,"severity":"error","filePath":"core/iox_v1_query_api/src/error.rs","lineNumber":35,"sourceCode":"pub 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),\n\n    // SerdeJsonError\n    #[error(\"error decoding query body: {0}\")]\n    SerdeJson(#[from] serde_json::Error),\n\n    #[error(\"datafusion error: {0}\")]\n    Datafusion(#[from] DataFusionError),\n\n    #[error(\"error in InfluxQL statement: {0}\")]\n    InfluxqlRewrite(#[from] rewrite::Error),","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/iox_v1_query_api/src/error.rs#L17-L53","documentation":"`Error::Utf8 { message, error }` indicates a request payload was not valid UTF-8. The v1 API requires text-based bodies/parameters; decoding a byte payload as UTF-8 fails and the error carries both a static context `message` and the underlying `error` string.","triggerScenarios":"Sending query bodies, form values, or uploaded files containing invalid UTF-8 byte sequences (e.g. Latin-1 encoded text, binary data, or truncated multibyte characters).","commonSituations":"Files saved in Windows-1252/ISO-8859-1 encodings uploaded as line protocol, gzip data sent uncompressed/unflagged, or strings containing stray binary bytes.","solutions":["Re-encode the payload as UTF-8 before sending (e.g. `iconv -f ISO-8859-1 -t UTF-8`).","Ensure files are text, not binary; do not send compressed bytes unless the API expects them.","Use `String::from_utf8` client-side to validate payloads before transmission."],"exampleFix":"// before\nlet body = legacy_latin1_bytes; // invalid UTF-8\n// after\nlet body = String::from_utf8(legacy_latin1_bytes).expect(\"payload must be utf-8\");","handlingStrategy":"validation","validationCode":"fn ensure_utf8(bytes: &[u8]) -> Result<&str, std::str::Utf8Error> {\n    std::str::from_utf8(bytes)\n}","typeGuard":"fn is_utf8_error(e: &iox_v1_query_api::Error) -> bool {\n    matches!(e, iox_v1_query_api::Error::Utf8 { .. })\n}","tryCatchPattern":"let payload = ensure_utf8(&raw).map_err(|e| format!(\"payload not utf-8: {e}\"))?;\nlet resp = client.post(\"/query\").body(payload.to_owned()).send().await?;","preventionTips":["Convert files to UTF-8 once at ingestion time (iconv or editor save-as).","Never send binary/compressed bytes unless the endpoint explicitly accepts them.","Add `String::from_utf8` checks in upload scripts to fail fast before the network call."],"tags":["rust","http-api","utf8","encoding","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"}