From 12bd77454ba98b1a56700522bc07b31a3b3af054 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Sun, 7 Sep 2025 01:04:18 +0000 Subject: [PATCH 1/5] For h2, uri path should be explicitly matched --- .../src/layer/alb_health_check.rs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs b/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs index 8c76bf1a9f3..798ac77b91d 100644 --- a/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs +++ b/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs @@ -108,7 +108,7 @@ where } fn call(&mut self, req: Request) -> Self::Future { - if req.uri() == self.layer.health_check_uri.as_ref() { + if req.uri().path() == self.layer.health_check_uri.as_ref() { let clone = self.layer.health_check_handler.clone(); let service = std::mem::replace(&mut self.layer.health_check_handler, clone); let handler_future = service.oneshot(req); @@ -179,3 +179,32 @@ where } } } + +#[cfg(test)] +mod tests { + use super::*; + use http::Uri; + use tower::{service_fn, ServiceExt}; + + #[tokio::test] + async fn health_check_matches_path_with_scheme_and_authority() { + let layer = AlbHealthCheckLayer::from_handler("/ping", |_req| async { StatusCode::OK }); + + let inner_service = service_fn(|_req| async { + Ok::<_, std::convert::Infallible>( + Response::builder() + .status(StatusCode::IM_A_TEAPOT) + .body(crate::body::empty()) + .expect("infallible"), + ) + }); + + let service = layer.layer(inner_service); + + let uri: Uri = "https://example.com/ping".parse().unwrap(); + let request = Request::builder().uri(uri).body(Body::empty()).unwrap(); + + let response = service.oneshot(request).await.unwrap(); + assert_eq!(response.status(), StatusCode::OK); + } +} From 0543dab9c8cfc9bc8f07462d82148b908261ab27 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Sun, 7 Sep 2025 01:08:55 +0000 Subject: [PATCH 2/5] add changelog entry --- .changelog/1757207291.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changelog/1757207291.md diff --git a/.changelog/1757207291.md b/.changelog/1757207291.md new file mode 100644 index 00000000000..3ddc103e899 --- /dev/null +++ b/.changelog/1757207291.md @@ -0,0 +1,10 @@ +--- +applies_to: [server] +authors: [drganjoo] +references: [] +breaking: false +new_feature: false +bug_fix: true +--- +Fixed URI path matching for H2 protocol in the ALB health check layer to ensure explicit path comparison. + From aef9c71f6ddb7e20ca19f4b54a3390ac3adf82db Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Sun, 7 Sep 2025 09:01:25 +0000 Subject: [PATCH 3/5] Bump smithy server version --- rust-runtime/aws-smithy-http-server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-http-server/Cargo.toml b/rust-runtime/aws-smithy-http-server/Cargo.toml index 76d5051bfcd..96b8e6c0977 100644 --- a/rust-runtime/aws-smithy-http-server/Cargo.toml +++ b/rust-runtime/aws-smithy-http-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws-smithy-http-server" -version = "0.65.5" +version = "0.66.0" authors = ["Smithy Rust Server "] edition = "2021" license = "Apache-2.0" From fc73951b422de297a8e89407fd50d5f397c82f67 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Tue, 9 Sep 2025 15:54:29 +0100 Subject: [PATCH 4/5] Add uri_with_only_path test --- .../src/layer/alb_health_check.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs b/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs index 798ac77b91d..656f511d726 100644 --- a/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs +++ b/rust-runtime/aws-smithy-http-server/src/layer/alb_health_check.rs @@ -187,9 +187,19 @@ mod tests { use tower::{service_fn, ServiceExt}; #[tokio::test] - async fn health_check_matches_path_with_scheme_and_authority() { - let layer = AlbHealthCheckLayer::from_handler("/ping", |_req| async { StatusCode::OK }); + async fn health_check_matches_path_when_uri_contains_scheme_authority_and_path() { + let uri: Uri = "https://example.com/ping".parse().unwrap(); + ensure_health_check_path_matches(uri, "/ping".to_string()).await; + } + + #[tokio::test] + async fn health_check_matches_path_when_uri_contains_only_path() { + let uri: Uri = "/ping".parse().unwrap(); + ensure_health_check_path_matches(uri, "/ping".to_string()).await; + } + async fn ensure_health_check_path_matches(uri: Uri, health_check_path: String) { + let layer = AlbHealthCheckLayer::from_handler(health_check_path, |_req| async { StatusCode::OK }); let inner_service = service_fn(|_req| async { Ok::<_, std::convert::Infallible>( Response::builder() @@ -200,10 +210,7 @@ mod tests { }); let service = layer.layer(inner_service); - - let uri: Uri = "https://example.com/ping".parse().unwrap(); let request = Request::builder().uri(uri).body(Body::empty()).unwrap(); - let response = service.oneshot(request).await.unwrap(); assert_eq!(response.status(), StatusCode::OK); } From 95e4742556d60a7dee137fc692908bbd67db80b9 Mon Sep 17 00:00:00 2001 From: Fahad Zubair Date: Thu, 11 Sep 2025 18:28:03 +0100 Subject: [PATCH 5/5] Change minor version only for aws-smithy-http-server --- rust-runtime/aws-smithy-http-server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-runtime/aws-smithy-http-server/Cargo.toml b/rust-runtime/aws-smithy-http-server/Cargo.toml index 96b8e6c0977..507835428c9 100644 --- a/rust-runtime/aws-smithy-http-server/Cargo.toml +++ b/rust-runtime/aws-smithy-http-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws-smithy-http-server" -version = "0.66.0" +version = "0.65.6" authors = ["Smithy Rust Server "] edition = "2021" license = "Apache-2.0"