From 06f0e06fc15c4acc55aa8f6da0e305d7a013aaa3 Mon Sep 17 00:00:00 2001 From: Matheus Oliveira <99829531+omatheusmesmo@users.noreply.github.com> Date: Mon, 12 Oct 2026 19:37:37 -0300 Subject: [PATCH] fix(ec2): return real AWS error for unknown availability zone name (#5529) DescribeAvailabilityZones now answers unknown ZoneNames with the same message AllocateHosts uses, 'Invalid availability zone: []', matching real AWS responses quoted in eksctl-io/eksctl#8174, instead of 'The zone name ... is not valid for this region.' The integration test now asserts the exact message. ZoneId behavior is unchanged. Signed-off-by: Matheus Oliveira --- .../io/github/hectorvent/floci/services/ec2/Ec2Service.java | 2 +- .../hectorvent/floci/services/ec2/Ec2IntegrationTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java index 3283d4f703..7e14cd82bf 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java +++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2Service.java @@ -9352,7 +9352,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab } if (!found) { throw new AwsException("InvalidParameterValue", - "The zone name '" + requestedName + "' is not valid for this region.", 400); + "Invalid availability zone: [" + requestedName + "]", 400); } } allZones.removeIf(az -> !requestedNames.contains(az.get("zoneName"))); diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java index 1ae317adfd..de30e52879 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java @@ -207,7 +207,8 @@ class Ec2IntegrationTest { .post("/") .then() .statusCode(400) - .body("Response.Errors.Error.Code", equalTo("InvalidParameterValue")); + .body("Response.Errors.Error.Code", equalTo("InvalidParameterValue")) + .body("Response.Errors.Error.Message", equalTo("Invalid availability zone: [us-east-1aa]")); } @Test