vectordotdev/vector · error
Invalid http request value used
Error message
Invalid http request value used
What it means
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'.
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
Example fix
// before
let mut request = builder.body(es_req.payload).expect("Invalid http request value used");
// after
let mut request = builder.body(es_req.payload).map_err(|e| crate::Error::from(e))?; Defensive patterns
Strategy: validation
Validate before calling
// rust: validate URI and headers before building
let uri: http::Uri = endpoint.parse().map_err(|_| anyhow!("invalid endpoint URI"))?;
for (h, v) in &headers { HeaderValue::from_str(v).map_err(|_| anyhow!("invalid header value"))?; } Type guard
fn is_valid_uri(s: &str) -> bool { s.parse::<http::Uri>().is_ok() } Try / catch
let request = builder.body(es_req.payload).map_err(|e| anyhow!("failed to build ES request: {e}"))?; Prevention
- 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
When it happens
Trigger: 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.
Common situations: Misconfigured endpoint URL in the Elasticsearch sink config; invalid characters in custom headers; invalid bulk action URIs derived from index templates.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- a record with a next ID must have an event count
- a valid HTTP/1 URI is valid as an HTTP URI
- a validated HTTP endpoint is a valid `http 1` URI
- all json-file keys should be matched
- all-of subschemas must be present here
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/5f7a977732e458d6.
Report an issue: GitHub.
Appendix: source
Thrown at src/sinks/elasticsearch/service.rs:139
let mut builder = Request::post(&self.bulk_uri);
builder = builder.header("Content-Type", "application/x-ndjson");
if let Some(ce) = self.compression.content_encoding() {
builder = builder.header("Content-Encoding", ce);
}
if let Some(ae) = self.compression.accept_encoding() {
builder = builder.header("Accept-Encoding", ae);
}
for (header, value) in &self.http_request_config.headers {
builder = builder.header(header.as_str(), value.as_str());
}
let mut request = builder
.body(es_req.payload)
.expect("Invalid http request value used");
if let Some(auth) = &self.auth {
match auth {
Auth::Basic(auth) => {
auth.apply(&mut request);
}
#[cfg(feature = "aws-core")]
Auth::Aws {
credentials_provider: provider,
region,
} => {
crate::sinks::elasticsearch::sign_request(
&self.service_type,
&mut request,
provider,
Some(region),
)
.await?;View on GitHub (pinned to bdb87aeaa4)