From daecc6da17b6c1e422f89090c5ce7ae26ec862b8 Mon Sep 17 00:00:00 2001 From: Allen Sanborn Date: Wed, 23 Sep 2026 10:20:50 -0500 Subject: [PATCH] fix(route53resolver): CreateResolverEndpoint reads IpAddresses, as AWS names it (#4180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(route53resolver): CreateResolverEndpoint reads IpAddresses, as AWS names it CreateResolverEndpoint read its address list from a member called IpAddressRequests. AWS names that member IpAddresses; the list's SHAPE is named IpAddressRequest, which is where the wrong wire name came from. The distinction is not cosmetic. Every AWS SDK, the CLI and the Terraform provider serialise IpAddresses, and the CLI refuses to send IpAddressRequests at all because no such member exists in its model. So the operation dispatched and no real client could call it: {"Name":"ep","Direction":"INBOUND","SecurityGroupIds":["sg-1"], "IpAddresses":[{"SubnetId":"subnet-1"}]} -> 400 InvalidParameterException: IpAddressRequests is required That is the worst shape a gap can take, because every cheap check says the service works: it is in the service directory, /_floci/health lists it, an operation-name grep finds it, and a does-it-route probe passes. Reads IpAddresses, still accepting the old spelling so anything written against the previous behaviour keeps working — the existing CustomResources tests use it and are untouched. The error message names only the AWS member, since it is the sole hint a caller gets. The idempotency record keeps its internal member name deliberately: renaming it would make every endpoint stored by an earlier build read as absent, which that code reports as a replay conflict. Tests: the AWS member is accepted, the legacy one still is, a retry that switches between the two spellings is not a conflict, and the missing-member error names IpAddresses. 55 Route53Resolver tests pass. Reported as #4108. Found while confirming that an earlier finding — Route53Resolver absent entirely — had been fixed upstream: the probe written for it asserted only that the call dispatches, which is what let this hide behind it. * style: use -- rather than an em dash in added prose AGENTS.md forbids em dashes in all content and the conformance check flags them. Two in javadoc lines this branch added. Comments only, no behaviour change. * docs(route53resolver): name the list shape correctly, and trim the member note The list shape is `IpAddressesRequest`; `IpAddressRequest` is the shape of each element, and that element name is where the wrong wire spelling came from. Both the service doc and the Javadoc on ipAddressesOf had it as the list's own name. The Javadoc also carried a paragraph on how the bug stayed hidden, which the PR description already covers at length. What a reader of this method needs is the member name and the legacy alias, so that is what is left. --- docs/services/route53resolver.md | 9 +- .../Route53ResolverService.java | 23 ++++- .../Route53ResolverIntegrationTest.java | 86 +++++++++++++++++++ 3 files changed, 113 insertions(+), 5 deletions(-) diff --git a/docs/services/route53resolver.md b/docs/services/route53resolver.md index d1b9fc236c..ff378691e8 100644 --- a/docs/services/route53resolver.md +++ b/docs/services/route53resolver.md @@ -63,9 +63,14 @@ resource and raise `ResourceExistsException`, which both operations model. all, so a mismatched retry still returns the original list rather than an invented error code. See `issues/route53resolver-firewall-domain-list-retry-conflict.md`. -For `CreateResolverEndpoint` the comparison covers the actual `IpAddressRequests` entries, +For `CreateResolverEndpoint` the comparison covers the actual `IpAddresses` entries, not just how many there are, so a retry that keeps the count but changes a subnet or -address is a conflict. Order is not significant. The modelled `ResolverEndpoint` shape has +address is a conflict. The member is `IpAddresses`, as AWS names it; its list shape is +`IpAddressesRequest` and each element is an `IpAddressRequest`, which is the name earlier +builds of this service mistook for the wire name. +That spelling is still accepted so existing callers keep working, but it is not the +documented one, and a retry that switches between the two is not a conflict because the +comparison is on contents. Order is not significant. The modelled `ResolverEndpoint` shape has `IpAddressCount` and no IP list, so the addresses are recorded in a side store rather than on the resource and never reach the response. If that record is ever missing for a stored endpoint, the retry is reported as a conflict rather than compared on count alone — with diff --git a/src/main/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverService.java b/src/main/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverService.java index d2bf4086ec..7cfd83b5e0 100644 --- a/src/main/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverService.java +++ b/src/main/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverService.java @@ -176,9 +176,9 @@ public class Route53ResolverService { requireText(request, "Name", INVALID_PARAMETER); String direction = requireText(request, "Direction", INVALID_PARAMETER); String idPrefix = endpointIdPrefix(direction); - JsonNode ipAddresses = request.path("IpAddressRequests"); + JsonNode ipAddresses = ipAddressesOf(request); if (!ipAddresses.isArray() || ipAddresses.isEmpty()) { - throw new AwsException(INVALID_PARAMETER, "IpAddressRequests is required", 400); + throw new AwsException(INVALID_PARAMETER, "IpAddresses is required", 400); } java.util.Optional replay = replayOf(endpointStore, request, region); if (replay.isPresent()) { @@ -438,6 +438,9 @@ public class Route53ResolverService { * of this branch.

*/ private void requireSameIpRequests(ObjectNode existing, JsonNode request, JsonNode ipAddresses) { + // The store's member name is deliberately left as IpAddressRequests: it is internal + // state, and renaming it would make every record written by an earlier build read as + // absent, which this method reports as a replay conflict. JsonNode recorded = endpointIpRequestStore.get(text(existing, "Id")) .map(node -> node.get("IpAddressRequests")) .orElse(null); @@ -445,10 +448,24 @@ public class Route53ResolverService { // written before the ordering was corrected still compares as equal. if (recorded == null || !normalizedIpRequests(recorded).equals(normalizedIpRequests(ipAddresses))) { - throw replayConflict(request, existing, "IpAddressRequests"); + throw replayConflict(request, existing, "IpAddresses"); } } + /** + * The IP addresses a {@code CreateResolverEndpoint} request carries. + * + *

AWS names this member {@code IpAddresses}; its list shape is + * {@code IpAddressesRequest} and each element is an {@code IpAddressRequest}, which + * is the name the wrong wire spelling came from. {@code IpAddressRequests} is still + * accepted so anything written against the emulator's earlier behaviour keeps + * working, but it is undocumented and the error message names only the AWS member.

+ */ + private static JsonNode ipAddressesOf(JsonNode request) { + JsonNode aws = request.path("IpAddresses"); + return aws.isMissingNode() || aws.isNull() ? request.path("IpAddressRequests") : aws; + } + /** * The IP requests in a stable order, so a reordered retry is not read as a change. * diff --git a/src/test/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverIntegrationTest.java index 5c811e8eb8..42507d408a 100644 --- a/src/test/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/route53resolver/Route53ResolverIntegrationTest.java @@ -86,4 +86,90 @@ class Route53ResolverIntegrationTest { .then() .statusCode(400); } + + // ── CreateResolverEndpoint: the request member is IpAddresses ────────────── + // + // AWS names it IpAddresses; its list shape is named IpAddressRequest, which is + // where the emulator's earlier wire name came from. Every SDK, the CLI and the + // Terraform provider send IpAddresses, and the CLI will not send the old name at + // all, so reading only the old one made the operation dispatch and stay + // uncallable. These cover both spellings so the alias cannot be dropped silently. + + private static String createEndpointBody(String ipMember, String creatorRequestId) { + return "{\"Name\":\"ep\",\"Direction\":\"INBOUND\"," + + "\"CreatorRequestId\":\"" + creatorRequestId + "\"," + + "\"SecurityGroupIds\":[\"sg-abc123\"]," + + "\"" + ipMember + "\":[{\"SubnetId\":\"subnet-abc\",\"Ip\":\"10.0.0.10\"}]}"; + } + + @Test + void createResolverEndpoint_acceptsTheAwsIpAddressesMember() { + given() + .contentType(CONTENT_TYPE) + .header("X-Amz-Target", "Route53Resolver.CreateResolverEndpoint") + .header("Authorization", AUTH_HEADER) + .body(createEndpointBody("IpAddresses", "aws-member-1")) + .when() + .post("/") + .then() + .statusCode(200) + .body("ResolverEndpoint.Id", startsWith("rslvr-in-")) + .body("ResolverEndpoint.Direction", equalTo("INBOUND")) + .body("ResolverEndpoint.IpAddressCount", equalTo(1)); + } + + @Test + void createResolverEndpoint_stillAcceptsTheLegacyMember() { + given() + .contentType(CONTENT_TYPE) + .header("X-Amz-Target", "Route53Resolver.CreateResolverEndpoint") + .header("Authorization", AUTH_HEADER) + .body(createEndpointBody("IpAddressRequests", "legacy-member-1")) + .when() + .post("/") + .then() + .statusCode(200) + .body("ResolverEndpoint.IpAddressCount", equalTo(1)); + } + + @Test + void createResolverEndpoint_replayMatchesAcrossTheTwoSpellings() { + // A caller that created an endpoint with the old name and retries with the AWS + // one is sending the same request. The idempotency check compares contents, so + // it must not read the rename as a conflict. + given() + .contentType(CONTENT_TYPE) + .header("X-Amz-Target", "Route53Resolver.CreateResolverEndpoint") + .header("Authorization", AUTH_HEADER) + .body(createEndpointBody("IpAddressRequests", "replay-across-names")) + .when().post("/").then().statusCode(200); + + given() + .contentType(CONTENT_TYPE) + .header("X-Amz-Target", "Route53Resolver.CreateResolverEndpoint") + .header("Authorization", AUTH_HEADER) + .body(createEndpointBody("IpAddresses", "replay-across-names")) + .when() + .post("/") + .then() + .statusCode(200) + .body("ResolverEndpoint.IpAddressCount", equalTo(1)); + } + + @Test + void createResolverEndpoint_withoutAddressesNamesTheAwsMember() { + // The message is the only hint a caller gets about which member to send, so it + // must name the one AWS documents rather than the emulator's internal spelling. + given() + .contentType(CONTENT_TYPE) + .header("X-Amz-Target", "Route53Resolver.CreateResolverEndpoint") + .header("Authorization", AUTH_HEADER) + .body("{\"Name\":\"ep\",\"Direction\":\"INBOUND\"," + + "\"CreatorRequestId\":\"no-addresses\",\"SecurityGroupIds\":[\"sg-abc123\"]}") + .when() + .post("/") + .then() + .statusCode(400) + .body("message", equalTo("IpAddresses is required")); + } }