{"record":{"id":"2b47b16a18d89280","repo":"vectordotdev/vector","slug":"building-http-request-failed-unexpectedly","errorCode":null,"errorMessage":"building HTTP request failed unexpectedly","messagePattern":"building HTTP request failed unexpectedly","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/new_relic/service.rs","lineNumber":100,"sourceCode":"\n        let uri = request.credentials.get_uri();\n\n        let http_request = Request::post(&uri)\n            .header(CONTENT_TYPE, \"application/json\")\n            .header(\"Api-Key\", request.credentials.license_key.clone());\n\n        let http_request = if let Some(ce) = request.compression.content_encoding() {\n            http_request.header(CONTENT_ENCODING, ce)\n        } else {\n            http_request\n        };\n\n        let payload_len = request.payload.len();\n        let metadata = request.get_metadata().clone();\n        let http_request = http_request\n            .header(CONTENT_LENGTH, payload_len)\n            .body(Body::from(request.payload))\n            .expect(\"building HTTP request failed unexpectedly\");\n\n        Box::pin(async move {\n            match client.call(http_request).in_current_span().await {\n                Ok(_) => Ok(NewRelicApiResponse {\n                    event_status: EventStatus::Delivered,\n                    metadata,\n                }),\n                Err(_) => Err(NewRelicSinkError::new(\"HTTP request error\")),\n            }\n        })\n    }\n}\n","sourceCodeStart":82,"sourceCodeEnd":113,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sinks/new_relic/service.rs#L82-L113","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["rust","panic","http","new-relic","sink"],"backgroundTag":"internal-invariant-violation","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"}