{"record":{"id":"5f7a977732e458d6","repo":"vectordotdev/vector","slug":"invalid-http-request-value-used","errorCode":null,"errorMessage":"Invalid http request value used","messagePattern":"Invalid http request value used","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/elasticsearch/service.rs","lineNumber":139,"sourceCode":"        let mut builder = Request::post(&self.bulk_uri);\n\n        builder = builder.header(\"Content-Type\", \"application/x-ndjson\");\n\n        if let Some(ce) = self.compression.content_encoding() {\n            builder = builder.header(\"Content-Encoding\", ce);\n        }\n\n        if let Some(ae) = self.compression.accept_encoding() {\n            builder = builder.header(\"Accept-Encoding\", ae);\n        }\n\n        for (header, value) in &self.http_request_config.headers {\n            builder = builder.header(header.as_str(), value.as_str());\n        }\n\n        let mut request = builder\n            .body(es_req.payload)\n            .expect(\"Invalid http request value used\");\n\n        if let Some(auth) = &self.auth {\n            match auth {\n                Auth::Basic(auth) => {\n                    auth.apply(&mut request);\n                }\n                #[cfg(feature = \"aws-core\")]\n                Auth::Aws {\n                    credentials_provider: provider,\n                    region,\n                } => {\n                    crate::sinks::elasticsearch::sign_request(\n                        &self.service_type,\n                        &mut request,\n                        provider,\n                        Some(region),\n                    )\n                    .await?;","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sinks/elasticsearch/service.rs#L121-L157","documentation":"build_request in the Elasticsearch sink assembles the HTTP request with the configured method, URI, headers, compression and body via http::Request::builder. The builder's .body() returns Err for invalid combinations (e.g. invalid URI previously set); the expect turns that into the panic 'Invalid http request value used'.","triggerScenarios":"The request builder holds an invalid state — most commonly an invalid endpoint/URI, or an invalid header value — so .body(es_req.payload) returns an error.","commonSituations":"Misconfigured endpoint URL in the Elasticsearch sink config; invalid characters in custom headers; invalid bulk action URIs derived from index templates.","solutions":["Fix the endpoint/URI in the sink configuration","Check custom headers for invalid characters","Validate the endpoint URL with a parser before starting Vector","Return a proper error instead of expect when building the request"],"exampleFix":"// before\nlet mut request = builder.body(es_req.payload).expect(\"Invalid http request value used\");\n// after\nlet mut request = builder.body(es_req.payload).map_err(|e| crate::Error::from(e))?;","handlingStrategy":"validation","validationCode":"// rust: validate URI and headers before building\nlet uri: http::Uri = endpoint.parse().map_err(|_| anyhow!(\"invalid endpoint URI\"))?;\nfor (h, v) in &headers { HeaderValue::from_str(v).map_err(|_| anyhow!(\"invalid header value\"))?; }","typeGuard":"fn is_valid_uri(s: &str) -> bool { s.parse::<http::Uri>().is_ok() }","tryCatchPattern":"let request = builder.body(es_req.payload).map_err(|e| anyhow!(\"failed to build ES request: {e}\"))?;","preventionTips":["Validate endpoint URLs at config validation","Restrict header values to visible ASCII","Test index-template output for illegal URI characters","Convert builder errors into typed errors instead of panics"],"tags":["rust","elasticsearch","http-request"],"backgroundTag":"invalid-url-format","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}