{"record":{"id":"bc37ac1cdcfdd684","repo":"influxdata/influxdb","slug":"invalid-metadata-name","errorCode":null,"errorMessage":"Invalid metadata name","messagePattern":"Invalid metadata name","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/influxdb_iox_client/src/client/flight/mod.rs","lineNumber":210,"sourceCode":"#[derive(Debug)]\npub struct Client {\n    inner: FlightClient,\n}\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    }","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/influxdb_iox_client/src/client/flight/mod.rs#L192-L228","documentation":"Not a typed variant but a `panic!` via `.expect(\"Invalid metadata name\")` in `FlightClient::new`: converting a connection header name to a tonic `MetadataKey` failed. gRPC metadata keys must be valid HTTP/2 header names (visible ASCII, no invalid characters); the expect aborts the process instead of returning an error.","triggerScenarios":"Constructing a FlightClient from an IOx Connection whose headers map contains a name that violates gRPC metadata-key rules (invalid characters, non-ASCII, empty, or illegal header-name bytes).","commonSituations":"Config files or environment variables supplying header names with spaces, Unicode, or control characters; programmatically built header maps containing typos or placeholder keys.","solutions":["Inspect all header names in the IOx Connection config for invalid characters and correct them","Pre-validate names with `MetadataKey::from_bytes(...)` (or `from_str`) and handle the Result instead of relying on expect","Strip or reject non-conforming headers before building the client","Ensure header names are lowercase ASCII per gRPC metadata rules"],"exampleFix":"// before\nlet name = MetadataKey::<_>::from_bytes(name.as_str().as_bytes())\n    .expect(\"Invalid metadata name\");\n// after\nlet name = MetadataKey::<_>::from_bytes(name.as_str().as_bytes())\n    .map_err(|e| anyhow::anyhow!(\"invalid metadata name {:?}: {}\", name.as_str(), e))?;","handlingStrategy":"validation","validationCode":"use tonic::metadata::MetadataKey;\nfn valid_metadata_names(headers: &[(String, String)]) -> Result<(), String> {\n    for (name, _) in headers {\n        MetadataKey::from_bytes(name.as_bytes())\n            .map_err(|e| format!(\"invalid metadata name {:?}: {}\", name, e))?;\n    }\n    Ok(())\n}","typeGuard":"fn is_valid_metadata_key(name: &str) -> bool {\n    tonic::metadata::MetadataKey::from_bytes(name.as_bytes()).is_ok()\n}","tryCatchPattern":null,"preventionTips":["Validate all header names against gRPC metadata rules before constructing the client","Restrict header names to lowercase ASCII letters, digits, '-', '_', '.'","Reject or sanitize headers loaded from env vars and config files","Never rely on expect() in library call paths — validate inputs first"],"tags":["grpc","metadata","panic","configuration"],"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"}