fix(ecr): paginate repository descriptions (#7711)

Preserve named lookups and bind continuation tokens to region and account.

Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-11-06 20:47:00 -04:00
1 parent a14dc18feb
commit d6aed932a1
4 files changed
+125 -3

No files matched your search

@@ -241,14 +241,18 @@ public class EcrJsonHandler {
List<String> names = parseStringList(request.path("repositoryNames"));
String registryId = request.path("registryId").asText(null);
List<Repository> repos = service.describeRepositories(names, registryId, region);
PaginatedResult<Repository> page = service.describeRepositories(names, registryId, region,
parseMaxResults(request.path("maxResults")), request.path("nextToken").asText(null));
ObjectNode response = objectMapper.createObjectNode();
ArrayNode arr = objectMapper.createArrayNode();
for (Repository r : repos) {
for (Repository r : page.items()) {
arr.add(buildRepository(r));
}
response.set("repositories", arr);
if (page.nextToken() != null) {
response.put("nextToken", page.nextToken());
}
return Response.ok(response).build();
}
@@ -594,6 +594,27 @@ public class EcrService implements ResourceProvider {
return out;
}
public PaginatedResult<Repository> describeRepositories(List<String> repositoryNames, String registryId,
String region, Integer maxResults, String nextToken) {
if (repositoryNames != null && !repositoryNames.isEmpty()) {
if (maxResults != null || nextToken != null) {
throw new AwsException("InvalidParameterException",
"Pagination cannot be used with repositoryNames.", 400);
}
return new PaginatedResult<>(describeRepositories(repositoryNames, registryId, region), null);
}
if (maxResults != null && (maxResults < 1 || maxResults > 1000)) {
throw new AwsException("InvalidParameterException", "maxResults must be between 1 and 1000.", 400);
}
if (nextToken != null && nextToken.isEmpty()) {
throw new AwsException("InvalidParameterException", "Invalid nextToken.", 400);
}
return Pagination.paginate(describeRepositories(repositoryNames, registryId, region),
Repository::getRepositoryName, maxResults == null ? 100 : maxResults, nextToken,
"ecr-describe-repositories:" + region + ":" + effectiveAccount(registryId),
token -> new AwsException("InvalidParameterException", "Invalid nextToken.", 400));
}
public record ScanningConfigurationFailure(String repositoryName, String failureCode, String failureReason) {}
public record BatchScanningConfigurationResult(List<Repository> repositories,