vectordotdev/vector · error
building HTTP request failed unexpectedly
Error message
building HTTP request failed unexpectedly
What it means
The New Relic sink service finalizes an HTTP request by setting Content-Length and a body from an already-validated Bytes payload, then unwraps construction with expect. Building a request with an http::Uri previously validated in the sink builder cannot fail, so the panic marks a broken internal invariant rather than a network or API problem.
Solutions
- No user action needed for stock builds.
- If encountered in a fork, review changes to New Relic request construction (src/sinks/new_relic/service.rs) and the license_key/URI header values.
- Update http/hyper dependencies to consistent versions.
Defensive patterns
Strategy: fallback
Prevention
- Use stock Vector builds and dependency versions.
- Run `vector validate` to catch URI/header problems at build time instead.
- Keep http/hyper crates version-aligned in forks.
When it happens
Trigger: The partially built http::Request (created in the sink's build_healthcheck/build phase) fails .header(CONTENT_LENGTH, len).body(...) — not reachable with a valid Uri header value and Bytes body.
Common situations: Practically unreachable; could only surface with a patched http crate or code changes altering how the base request/URI is constructed in src/sinks/new_relic.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- HTTP status codes are valid u16 values
- a valid HTTP/1 URI is valid as an HTTP URI
- a validated HTTP endpoint is a valid `http 1` URI
- Building request never fails.
- Could not convert HTTP status code to JSON
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/2b47b16a18d89280.
Report an issue: GitHub.
Appendix: source
Thrown at src/sinks/new_relic/service.rs:100
let uri = request.credentials.get_uri();
let http_request = Request::post(&uri)
.header(CONTENT_TYPE, "application/json")
.header("Api-Key", request.credentials.license_key.clone());
let http_request = if let Some(ce) = request.compression.content_encoding() {
http_request.header(CONTENT_ENCODING, ce)
} else {
http_request
};
let payload_len = request.payload.len();
let metadata = request.get_metadata().clone();
let http_request = http_request
.header(CONTENT_LENGTH, payload_len)
.body(Body::from(request.payload))
.expect("building HTTP request failed unexpectedly");
Box::pin(async move {
match client.call(http_request).in_current_span().await {
Ok(_) => Ok(NewRelicApiResponse {
event_status: EventStatus::Delivered,
metadata,
}),
Err(_) => Err(NewRelicSinkError::new("HTTP request error")),
}
})
}
}
View on GitHub (pinned to bdb87aeaa4)