{"record":{"id":"bdcc8e960a68b34e","repo":"influxdata/influxdb","slug":"invalid-metadata-value","errorCode":null,"errorMessage":"Invalid metadata value","messagePattern":"Invalid metadata value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/influxdb_iox_client/src/client/flight/mod.rs","lineNumber":213,"sourceCode":"}\n\nimpl Client {\n    /// Creates a new client with the provided [`Connection`]. Panics\n    /// if the metadata in connection is invalid for the underlying\n    /// tonic library.\n    pub fn new(connection: Connection) -> Self {\n        // Extract headers to include with each request\n        let (channel, headers) = connection.into_grpc_connection().into_parts();\n\n        let mut inner = FlightClient::new(channel);\n\n        // Copy any headers from IOx Connection\n        for (name, value) in headers.iter() {\n            let name = MetadataKey::<_>::from_bytes(name.as_str().as_bytes())\n                .expect(\"Invalid metadata name\");\n\n            let value: MetadataValue<_> =\n                value.as_bytes().try_into().expect(\"Invalid metadata value\");\n            inner.metadata_mut().insert(name, value);\n        }\n\n        Self { inner }\n    }\n\n    /// Return the inner arrow flight client\n    pub fn into_inner(self) -> FlightClient {\n        self.inner\n    }\n\n    /// Get a mutable reference to the inner arrow flight client\n    pub fn inner(&mut self) -> &mut FlightClient {\n        &mut self.inner\n    }\n\n    /// Return a reference to gRPC metadata included with each request\n    pub fn metadata(&self) -> &MetadataMap {","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_iox_client/src/client/flight/mod.rs#L195-L231","documentation":"A `panic!` via `.expect(\"Invalid metadata value\")` in `FlightClient::new`: converting a connection header value into a tonic `MetadataValue` failed. gRPC metadata values must be valid ASCII (or valid binary-flagged) strings; a failing `try_into` aborts the process rather than returning an error.","triggerScenarios":"Constructing a FlightClient from an IOx Connection whose headers map contains a value with non-ASCII or otherwise gRPC-illegal bytes — e.g. a token pasted with smart quotes, a UTF-8 header value, or binary junk.","commonSituations":"Auth tokens or secrets copied from documents/terminals containing non-ASCII characters; values containing newlines or control characters from multi-line env vars; encoding issues when values pass through shells or YAML config.","solutions":["Re-enter the header value ensuring pure visible ASCII (regenerate tokens if needed)","Pre-validate values with `MetadataValue::try_from(...)` and handle the Result instead of expect","Trim whitespace/newlines from values sourced from env vars or config files","Check for and remove smart quotes or invisible Unicode from copied credentials"],"exampleFix":"// before\nlet value: MetadataValue<_> =\n    value.as_bytes().try_into().expect(\"Invalid metadata value\");\n// after\nlet value: MetadataValue<_> = value.as_bytes().try_into()\n    .map_err(|e| anyhow::anyhow!(\"invalid metadata value: {}\", e))?;","handlingStrategy":"validation","validationCode":"use tonic::metadata::MetadataValue;\nfn valid_metadata_values(headers: &[(String, String)]) -> Result<(), String> {\n    for (_, value) in headers {\n        MetadataValue::try_from(value.as_bytes())\n            .map_err(|e| format!(\"invalid metadata value: {}\", e))?;\n    }\n    Ok(())\n}","typeGuard":"fn is_valid_metadata_value(value: &str) -> bool {\n    tonic::metadata::MetadataValue::try_from(value.as_bytes()).is_ok()\n}","tryCatchPattern":null,"preventionTips":["Ensure header values (tokens, IDs) are pure visible ASCII","Trim newlines/whitespace from values sourced from env vars or YAML","Regenerate credentials if they contain non-ASCII (e.g. smart quotes from copy/paste)","Pre-validate with MetadataValue::try_from before inserting into the client"],"tags":["grpc","metadata","panic","authentication"],"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"}