mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(route53resolver): CreateResolverEndpoint reads IpAddresses, as AWS names it (#4180)
* 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.
This commit is contained in:
1 parent
b2e2d116d8
commit
daecc6da17
3 files changed
+113
-5
No files matched your search
+20
-3
@@ -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<ObjectNode> replay = replayOf(endpointStore, request, region);
|
||||
if (replay.isPresent()) {
|
||||
@@ -438,6 +438,9 @@ public class Route53ResolverService {
|
||||
* of this branch.</p>
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* <p>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.</p>
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user