{"record":{"id":"6a046511e9931af3","repo":"influxdata/influxdb","slug":"invalid-utf8-in-response-0","errorCode":null,"errorMessage":"invalid UTF8 in response: {0}","messagePattern":"invalid UTF8 in response: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_client/src/lib.rs","lineNumber":47,"sourceCode":"    RequestUrl(#[from] url::ParseError),\n\n    #[error(\"failed to read the API response bytes: {}\", reqwest_description(.0))]\n    Bytes(#[source] reqwest::Error),\n\n    #[error(\"failed to serialize the request body: {0}\")]\n    RequestSerialization(#[source] serde_json::Error),\n\n    #[error(\n        \"provided parameter ('{name}') could not be converted \\\n        to a statment parameter\"\n    )]\n    ConvertQueryParam {\n        name: String,\n        #[source]\n        source: iox_query_params::Error,\n    },\n\n    #[error(\"invalid UTF8 in response: {0}\")]\n    InvalidUtf8(#[from] FromUtf8Error),\n\n    #[error(\"failed to parse JSON response: {}\", reqwest_description(.0))]\n    Json(#[source] reqwest::Error),\n\n    #[error(\"failed to parse plaintext response: {}\", reqwest_description(.0))]\n    Text(#[source] reqwest::Error),\n\n    #[error(\"server responded with error [{code}]: {message}\")]\n    ApiError {\n        code: StatusCode,\n        message: String,\n        /// Machine-readable error code from JSON error responses, if present.\n        error_code: Option<String>,\n    },\n\n    #[error(\"failed to send {method} {url} request: {}\", reqwest_description(.source))]\n    RequestSend {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_client/src/lib.rs#L29-L65","documentation":"Error::InvalidUtf8 wraps a std::string::FromUtf8Error produced when the client collects a response body into a String and the bytes are not valid UTF-8. The plaintext/JSON response could not be decoded as text.","triggerScenarios":"Calling query or metadata APIs whose response body contains non-UTF-8 bytes — e.g. a server or proxy emitting compressed/binary content, charset mismatches, or corrupted responses.","commonSituations":"Misconfigured proxies returning gzip without content-encoding headers; responses in unexpected encodings; reading binary error pages as text.","solutions":["Fetch raw bytes and decode explicitly, checking the Content-Type/charset header before conversion.","Verify no intermediary (proxy/LB) is mangling or compressing the response unexpectedly.","If the server may emit non-UTF-8, handle bytes with String::from_utf8 manually and report/repair encoding there."],"exampleFix":"// before\nlet text = resp.text().await?; // -> Error::InvalidUtf8\n// after\nlet bytes = resp.bytes().await?;\nlet text = String::from_utf8(bytes.to_vec())\n    .map_err(|e| eprintln!(\"lossy decode: {}\", e))\n    .unwrap_or_else(|_| String::from_utf8_lossy(&bytes).into_owned());","handlingStrategy":"try-catch","validationCode":"// inspect content-type before text conversion\nfn is_text(ct: &str) -> bool { ct.starts_with(\"text/\") || ct.contains(\"json\") }","typeGuard":null,"tryCatchPattern":"match client.call(...).await {\n    Err(Error::InvalidUtf8(e)) => {\n        log::warn!(\"non-UTF8 response: {e}; fetching bytes and lossy-decoding\");\n        decode_lossy_fallback().await\n    }\n    other => other,\n}","preventionTips":["Check Content-Type/Content-Encoding headers before decoding as text.","Bypass or reconfigure proxies that alter response encodings.","Fall back to from_utf8_lossy for diagnostics while alerting on encoding violations."],"tags":["utf8","encoding","response-body"],"backgroundTag":"json-decode-failed","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"}