mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(core): name the real pagination parameter in invalid-token errors (#5776)
* fix(core): name the real pagination parameter in invalid-token errors The maxResults/nextToken overload of Pagination.paginate hardcoded "Invalid nextToken." for a token that does not decode. Redshift DescribeSnapshotCopyGrants and the DMS Describe* operations take that token as Marker, so a malformed marker produced an error naming a parameter those operations do not have. Add an overload taking the wire name of the token parameter and use it in the message; the existing overloads delegate with "nextToken", so every NextToken caller is unchanged. The Redshift and both DMS call sites (DescribeReplicationSubnetGroups and the shared describe used by DescribeEndpoints, DescribeReplicationInstances and DescribeReplicationTasks) now pass "Marker". * fix(redshift,ce): name Marker and NextPageToken in invalid-token errors DescribeSnapshotSchedules (added in #5574) takes its page token as Marker but went through the paginate overload that reports "Invalid nextToken.". Cost Explorer GetAnomalyMonitors and GetAnomalySubscriptions take NextPageToken and had the same message. Both now pass the wire name to the tokenName overload. These were the remaining paginate callers whose token parameter is not nextToken; callers that render their own token error (Lambda durable executions, Auto Scaling, SES, Cognito) are unaffected.
This commit is contained in:
1 parent
832f1008bb
commit
0264c1b960
9 files changed
+63
-6
No files matched your search
@@ -85,6 +85,14 @@ class PaginationTest {
|
||||
assertEquals("Invalid nextToken.", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void legacyPaging_namesTheTokenParameterTheCallerGives() {
|
||||
AwsException e = assertThrows(AwsException.class, () -> Pagination.paginate(ITEMS,
|
||||
Function.identity(), 1, "!!!", 3, 3, "InvalidParameterValue", "Marker"));
|
||||
assertEquals("InvalidParameterValue", e.getErrorCode());
|
||||
assertEquals("Invalid Marker.", e.getMessage());
|
||||
}
|
||||
|
||||
private static PaginatedResult<String> page(int limit, String token, String namespace) {
|
||||
return Pagination.paginate(ITEMS, Function.identity(), limit, token, namespace, INVALID_TOKEN);
|
||||
}
|
||||
|
||||
@@ -190,6 +190,9 @@ class CostAnomalyServiceTest {
|
||||
() -> service.getMonitors(mapper.createObjectNode().put("MaxResults", 0)));
|
||||
assertError("InvalidNextTokenException",
|
||||
() -> service.getMonitors(mapper.createObjectNode().put("NextPageToken", "!not-base64")));
|
||||
AwsException badToken = assertThrows(AwsException.class,
|
||||
() -> service.getSubscriptions(mapper.createObjectNode().put("NextPageToken", "!not-base64")));
|
||||
assertEquals("Invalid NextPageToken.", badToken.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -193,6 +193,19 @@ class DmsServiceTest {
|
||||
second.items().stream().map(ReplicationSubnetGroup::getReplicationSubnetGroupIdentifier).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeRejectsMalformedMarkerNamingMarker() {
|
||||
AwsException groups = assertThrows(AwsException.class,
|
||||
() -> service.describeReplicationSubnetGroups(pageRequest(20, "!!!"), REGION));
|
||||
assertEquals("InvalidParameterValueException", groups.getErrorCode());
|
||||
assertEquals("Invalid Marker.", groups.getMessage());
|
||||
|
||||
AwsException endpoints = assertThrows(AwsException.class,
|
||||
() -> service.describeEndpoints(pageRequest(20, "!!!"), REGION));
|
||||
assertEquals("InvalidParameterValueException", endpoints.getErrorCode());
|
||||
assertEquals("Invalid Marker.", endpoints.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeDefaultsToOneHundredRecordsPerPage() {
|
||||
createGroups(25);
|
||||
|
||||
@@ -1153,4 +1153,12 @@ public class RedshiftOperationsTest {
|
||||
|
||||
assertEquals(200, redshift("DeleteCluster", "ClusterIdentifier", "cluster-sched").statusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
void describeSnapshotSchedulesRejectsMalformedMarkerNamingMarker() {
|
||||
Response response = redshift("DescribeSnapshotSchedules", "Marker", "!!!");
|
||||
assertFault(response, 400, "InvalidParameterValue");
|
||||
assertEquals("Invalid Marker.", XmlPath.from(response.asString()).getString("ErrorResponse.Error.Message"));
|
||||
}
|
||||
}
|
||||
@@ -1678,6 +1678,16 @@ class RedshiftServiceTest {
|
||||
assertNull(second.nextToken(), "last page must not carry a marker");
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeSnapshotCopyGrantsRejectsMalformedMarkerNamingMarker() {
|
||||
when(snapshotCopyGrantBackend.scan(any())).thenReturn(List.of(new SnapshotCopyGrant("grant-a", "key-a")));
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> service.describeSnapshotCopyGrants(null, null, "!!!"));
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
assertEquals("Invalid Marker.", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeSnapshotCopyGrantsOmitsMarkerWhenPageExactlyFits() {
|
||||
List<SnapshotCopyGrant> stored = new ArrayList<>();
|
||||
|
||||
Reference in new issue
Block a user