{"record":{"id":"593f0f1c0697d418","repo":"influxdata/influxdb","slug":"to-str-error-0","errorCode":null,"errorMessage":"to str error: {0}","messagePattern":"to str error: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"influxdb3_server/src/http.rs","lineNumber":303,"sourceCode":"\n    /// Arrow error\n    #[error(\"arrow error: {0}\")]\n    Arrow(#[from] arrow::error::ArrowError),\n\n    /// Hyper error\n    #[error(\"hyper http error: {0}\")]\n    Hyper(#[from] hyper::http::Error),\n\n    /// WriteBuffer error\n    #[error(\"write buffer error: {0}\")]\n    WriteBuffer(#[from] influxdb3_write::write_buffer::Error),\n\n    /// Persister error\n    #[error(\"persister error: {0}\")]\n    Persister(#[from] influxdb3_write::persister::PersisterError),\n\n    // ToStrError\n    #[error(\"to str error: {0}\")]\n    ToStr(#[from] hyper::header::ToStrError),\n\n    // SerdeJsonError\n    #[error(\"serde json error: {0}\")]\n    SerdeJson(#[from] serde_json::Error),\n\n    // Influxdb3 Write\n    #[error(\"serde json error: {0}\")]\n    Influxdb3Write(#[from] influxdb3_write::Error),\n\n    #[error(\"datafusion error: {0}\")]\n    Datafusion(#[from] DataFusionError),\n\n    #[error(\"io error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    #[error(\"query error: {0}\")]\n    Query(#[from] QueryExecutorError),","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_server/src/http.rs#L285-L321","documentation":"Wraps hyper::header::ToStrError via #[from]. HTTP header values are byte slices; converting one to &str fails if it contains non-ASCII bytes. The server rejects such requests with 'to str error: ...'.","triggerScenarios":"Any request whose header (e.g. Authorization, Content-Type, Accept) contains bytes outside valid ASCII/UTF-8 when the handler calls header.to_str().","commonSituations":"Clients that base64-decode incorrectly into raw bytes for Authorization; legacy encoders using ISO-8859-1 in headers; corrupted requests from proxies.","solutions":["Send header values as printable ASCII only","If a token must carry binary data, base64-encode it (standard charset)","Fix the client that generates the offending header","Capture the raw request to identify which header contains non-ASCII bytes"],"exampleFix":"// before\nrequest.headers.set(\"Authorization\", \"Basic \" + rawBytes) // raw non-ascii bytes\n// after\nrequest.headers.set(\"Authorization\", \"Basic \" + btoa(username + \":\" + password))","handlingStrategy":"validation","validationCode":"for (const [k, v] of Object.entries(headers)) {\n  if (!/^[\\x20-\\x7E]*$/.test(v)) throw new Error(`header ${k} has non-ASCII bytes`);\n}","typeGuard":"function isAsciiHeaderValue(v) { return typeof v === \"string\" && /^[\\x20-\\x7E]*$/.test(v); }","tryCatchPattern":"try { await send(req); } catch (e) {\n  if (String(e).includes(\"to str error\")) {\n    // locate the non-ASCII header, sanitize, resend\n  }\n}","preventionTips":["Base64-encode tokens instead of embedding raw bytes in headers","Restrict header construction to string constants and validated values","Reject non-ASCII header input at the client boundary","Capture raw requests when debugging header-related 400s"],"tags":["http","header","encoding","hyper"],"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"}