{"record":{"id":"5c54b1371c35ff56","repo":"vectordotdev/vector","slug":"error-creating-request","errorCode":null,"errorMessage":"error creating request","messagePattern":"error creating request","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/aws_ecs_metrics/mod.rs","lineNumber":192,"sourceCode":"    fn can_acknowledge(&self) -> bool {\n        false\n    }\n}\n\nasync fn aws_ecs_metrics(\n    http_client: HttpClient,\n    url: String,\n    interval: Duration,\n    namespace: Option<String>,\n    mut out: SourceSender,\n    shutdown: ShutdownSignal,\n) -> Result<(), ()> {\n    let mut interval = IntervalStream::new(time::interval(interval)).take_until(shutdown);\n    let bytes_received = register!(BytesReceived::from(Protocol::HTTP));\n    while interval.next().await.is_some() {\n        let request = Request::get(&url)\n            .body(Body::empty())\n            .expect(\"error creating request\");\n        let uri = request.uri().clone();\n\n        match http_client.send(request).await {\n            Ok(response) if response.status() == hyper::StatusCode::OK => {\n                match http_body::Body::collect(response.into_body())\n                    .await\n                    .map(Collected::to_bytes)\n                {\n                    Ok(body) => {\n                        bytes_received.emit(ByteSize(body.len()));\n\n                        match parser::parse(body.as_ref(), namespace.clone()) {\n                            Ok(metrics) => {\n                                let count = metrics.len();\n                                emit!(AwsEcsMetricsEventsReceived {\n                                    byte_size: metrics.estimated_json_encoded_size_of(),\n                                    count,\n                                    endpoint: uri.path(),","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sources/aws_ecs_metrics/mod.rs#L174-L210","documentation":"The aws_ecs_metrics source builds a GET request each polling interval and unwraps the builder result with expect(\"error creating request\"). The builder fails only when request components (the configured URL) are invalid, so a bad metrics/telemetry endpoint URL panics the polling task instead of surfacing a config error.","triggerScenarios":"Request::get(&url).body(Body::empty()) returning Err because the ECS metrics endpoint URL from configuration/environment (ECS_CONTAINER_METADATA_URI style) is not a valid URI.","commonSituations":"Running the source outside ECS with an unset or garbled metadata URI env var; misconfigured endpoint string with unencoded characters or empty value.","solutions":["Set the ECS endpoint URL correctly (valid absolute http URI, e.g. from ECS_CONTAINER_METADATA_URI).","Validate/parse the URL at source build time and fail config validation instead of panicking per interval.","Ensure environment substitution did not leave the endpoint empty or truncated."],"exampleFix":"// before\n.expect(\"error creating request\");\n// after\nlet request = Request::get(&url)\n    .body(Body::empty())\n    .map_err(|_| ())?; // skip this interval; log the invalid URL","handlingStrategy":"validation","validationCode":"let parsed = url::Url::parse(&endpoint).map_err(|e| format!(\"invalid ECS metrics endpoint: {e}\"))?;","typeGuard":null,"tryCatchPattern":"let request = Request::get(&url).body(Body::empty()).map_err(|e| { error!(%e, \"invalid ECS metrics URL\"); return Err(()); })?;","preventionTips":["Confirm ECS_CONTAINER_METADATA_URI (or equivalent) is set and well-formed before running the source.","Validate the URL at build time rather than inside the polling loop.","Log and skip invalid intervals instead of panicking."],"tags":["rust","panic","http","aws","ecs","uri"],"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"}