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

  1. No user action needed for stock builds.
  2. 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.
  3. Update http/hyper dependencies to consistent versions.
Defensive patterns

Strategy: fallback

Prevention

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


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)