{"record":{"id":"971590e81cd284f1","repo":"vectordotdev/vector","slug":"error-creating-request-mod","errorCode":null,"errorMessage":"error creating request","messagePattern":"error creating request","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/apache_metrics/mod.rs","lineNumber":163,"sourceCode":"    urls: Vec<http::Uri>,\n    interval: Duration,\n    namespace: Option<String>,\n    shutdown: ShutdownSignal,\n    mut out: SourceSender,\n    proxy: ProxyConfig,\n) -> super::Source {\n    Box::pin(async move {\n        let mut stream = IntervalStream::new(tokio::time::interval(interval))\n            .take_until(shutdown)\n            .map(move |_| stream::iter(urls.clone()))\n            .flatten()\n            .map(move |url| {\n                let client = HttpClient::new(None, &proxy).expect(\"HTTPS initialization failed\");\n                let sanitized_url = url.to_sanitized_string();\n\n                let request = Request::get(&url)\n                    .body(Body::empty())\n                    .expect(\"error creating request\");\n\n                let tags = metric_tags! {\n                    \"endpoint\" => sanitized_url.to_string(),\n                    \"host\" => url.sanitized_authority(),\n                };\n\n                let namespace = namespace.clone();\n                client\n                    .send(request)\n                    .map_err(crate::Error::from)\n                    .and_then(|response| async {\n                        let (header, body) = response.into_parts();\n                        let body = http_body::Body::collect(body).await?.to_bytes();\n                        Ok((header, body))\n                    })\n                    .into_stream()\n                    .filter_map(move |response| {\n                        ready(match response {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sources/apache_metrics/mod.rs#L145-L181","documentation":"The apache_metrics source constructs a GET request per URL and unwraps Request::get(&url).body(Body::empty()) with expect(\"error creating request\"). http::Request::builder only errors if the URI/method/headers are invalid, so this fires when a configured endpoint URL is not a valid URI.","triggerScenarios":"An apache_metrics endpoint value in config that fails URI parsing or validation when applied to the request builder (invalid scheme, characters, or empty URL).","commonSituations":"Typo or unencoded characters in the endpoints config (spaces, unencoded unicode); endpoints list containing an empty string after templating/env substitution.","solutions":["Fix the endpoints entries in the apache_metrics source config to be valid absolute http(s) URLs.","Validate URLs at config load time so bad endpoints are rejected during build rather than panicking at runtime.","URL-encode any dynamic path/query components before configuring endpoints."],"exampleFix":"// before\n.expect(\"error creating request\");\n// after\nlet request = Request::get(&url)\n    .body(Body::empty())\n    .map_err(|e| warn!(message = \"Skipping invalid endpoint.\", endpoint = %sanitized_url, %e))?;","handlingStrategy":"validation","validationCode":"url::Url::parse(&endpoint).map_err(|e| format!(\"invalid apache_metrics endpoint '{endpoint}': {e}\"))?;","typeGuard":null,"tryCatchPattern":"Request::get(&url).body(Body::empty()).map_err(|e| warn!(%e, \"invalid endpoint\"))?;","preventionTips":["Validate endpoint URLs in the source's config schema at load time.","URL-encode dynamic path/query segments.","Reject empty endpoint strings after env/templating substitution."],"tags":["rust","panic","http","uri","source"],"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"}