fix(glue): paginate security configurations (#6496)

* fix(glue): paginate security configurations

Honor GetSecurityConfigurations page size and continuation tokens using the existing Glue paging helper. Enforce the documented 1-200 range and preserve account and region isolation.

* refactor(glue): share action-specific pagination limits

Centralize range validation for security configurations, workflows and triggers. Defer list loading until after validation to preserve dependent-job error ordering and keep the existing default and general helper limit.
This commit is contained in:
Aniket Shukla authored and GitHub committed 2026-10-25 08:33:22 -04:00
1 parent 0a13e4259e
commit 9c8d2ba58d
5 files changed
+165 -20

No files matched your search

@@ -455,12 +455,15 @@ public class GlueJsonHandler {
glueService.deleteSecurityConfiguration(request.path("Name").asText(null), region);
yield Response.ok(Map.of()).build();
}
case "GetSecurityConfigurations" -> {
GlueService.Page<SecurityConfiguration> page = glueService.getSecurityConfigurations(
region, readMaxResults(request), readNextToken(request));
yield Response.ok(pageResponse("SecurityConfigurations", page.items(), page.nextToken())).build();
}
// Read-only Glue actions for resources the emulator does not model. The AWS SDK
// expects each to return a 200 with its result key present (empty), so we emit the
// documented empty shape rather than an InvalidAction 400 that callers can't read.
case "ListDataQualityRulesets" -> Response.ok(Map.of("Rulesets", List.of())).build();
case "GetSecurityConfigurations" -> Response.ok(Map.of(
"SecurityConfigurations", glueService.getSecurityConfigurations(region))).build();
case "CreateTrigger" -> {
Trigger trigger = toTrigger(request);
trigger.setName(request.path("Name").asText(null));
@@ -64,6 +64,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -320,6 +321,14 @@ public class GlueService {
return securityConfigurationStore.scan(key -> key.startsWith(prefix));
}
public Page<SecurityConfiguration> getSecurityConfigurations(String region, Integer maxResults, String nextToken) {
return paginate(() -> {
List<SecurityConfiguration> configurations = new ArrayList<>(getSecurityConfigurations(region));
configurations.sort(Comparator.comparing(SecurityConfiguration::getName));
return configurations;
}, maxResults, nextToken, 200);
}
private static String securityConfigurationKey(String region, String name) {
return region + ":" + name;
}
@@ -2243,16 +2252,14 @@ public class GlueService {
}
public Page<String> listWorkflows(Integer maxResults, String nextToken) {
if (maxResults != null && (maxResults < 1 || maxResults > MAX_WORKFLOWS_PAGE_SIZE)) {
throw new AwsException("InvalidInputException",
"MaxResults must be between 1 and " + MAX_WORKFLOWS_PAGE_SIZE, 400);
}
List<String> names = new ArrayList<>();
for (Workflow workflow : workflowStore.scan(k -> true)) {
names.add(workflow.getName());
}
names.sort(Comparator.naturalOrder());
return paginate(names, maxResults, nextToken);
return paginate(() -> {
List<String> names = new ArrayList<>();
for (Workflow workflow : workflowStore.scan(k -> true)) {
names.add(workflow.getName());
}
names.sort(Comparator.naturalOrder());
return names;
}, maxResults, nextToken, MAX_WORKFLOWS_PAGE_SIZE);
}
public BatchGetWorkflowsResult batchGetWorkflows(List<String> names) {
@@ -2365,11 +2372,7 @@ public class GlueService {
* all triggers are returned when none can.
*/
public Page<Trigger> getTriggers(String dependentJobName, Integer maxResults, String nextToken) {
if (maxResults != null && (maxResults < 1 || maxResults > MAX_TRIGGERS_PAGE_SIZE)) {
throw new AwsException("InvalidInputException",
"MaxResults must be between 1 and " + MAX_TRIGGERS_PAGE_SIZE, 400);
}
return paginate(triggersStarting(dependentJobName), maxResults, nextToken);
return paginate(() -> triggersStarting(dependentJobName), maxResults, nextToken, MAX_TRIGGERS_PAGE_SIZE);
}
public Page<String> listTriggers(String dependentJobName, Integer maxResults, String nextToken,
@@ -3011,9 +3014,14 @@ public class GlueService {
public record Page<T>(List<T> items, String nextToken) {}
<T> Page<T> paginate(List<T> all, Integer maxResults, String nextToken) {
if (maxResults != null && (maxResults < 1 || maxResults > 1000)) {
throw new AwsException("InvalidInputException", "MaxResults must be between 1 and 1000", 400);
return paginate(() -> all, maxResults, nextToken, 1000);
}
private <T> Page<T> paginate(Supplier<List<T>> items, Integer maxResults, String nextToken, int maximum) {
if (maxResults != null && (maxResults < 1 || maxResults > maximum)) {
throw new AwsException("InvalidInputException", "MaxResults must be between 1 and " + maximum, 400);
}
List<T> all = items.get();
int limit = maxResults == null ? 100 : maxResults;
int start = 0;
if (nextToken != null && !nextToken.isBlank()) {