fix(autoscaling): preserve indexed standby request members (#7205)

Preserve every positive indexed standby member for validation before mutation. Reuse the existing capacity-target parser and sort numeric indexes without integer conversion. Preserve accepted namespace assertions and current main behavior. Sparse AWS index acceptance is not claimed.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-11-01 11:27:24 -04:00
1 parent 24b152a274
commit dae514b6a2
3 files changed
+133 -5

No files matched your search

@@ -941,7 +941,7 @@ public class AutoScalingQueryHandler {
boolean shouldDecrement = requiredBoolParam(p, "ShouldDecrementDesiredCapacity",
"shouldDecrementDesiredCapacity");
return ok(activitiesResponse("EnterStandby",
service.enterStandby(region, groupName, memberList(p, "InstanceIds"), shouldDecrement)));
service.enterStandby(region, groupName, indexedMembers(p, "InstanceIds"), shouldDecrement)));
}
private Response handleExitStandby(MultivaluedMap<String, String> p, String region) {
@@ -950,7 +950,7 @@ public class AutoScalingQueryHandler {
throw SmithyValidationErrors.validationError(SmithyValidationErrors.notNull("autoScalingGroupName"));
}
return ok(activitiesResponse("ExitStandby",
service.exitStandby(region, groupName, memberList(p, "InstanceIds"))));
service.exitStandby(region, groupName, indexedMembers(p, "InstanceIds"))));
}
private static String activitiesResponse(String action, List<ScalingActivity> activities) {
@@ -1720,17 +1720,19 @@ public class AutoScalingQueryHandler {
CapacityReservationSpecification specification = new CapacityReservationSpecification();
specification.setCapacityReservationPreference(p.getFirst(prefix + "CapacityReservationPreference"));
specification.setCapacityReservationIds(
capacityTargetMembers(p, prefix + "CapacityReservationTarget.CapacityReservationIds"));
indexedMembers(p, prefix + "CapacityReservationTarget.CapacityReservationIds"));
specification.setCapacityReservationResourceGroupArns(
capacityTargetMembers(p, prefix + "CapacityReservationTarget.CapacityReservationResourceGroupArns"));
indexedMembers(p, prefix + "CapacityReservationTarget.CapacityReservationResourceGroupArns"));
return specification;
}
private List<String> capacityTargetMembers(MultivaluedMap<String, String> params, String prefix) {
private List<String> indexedMembers(MultivaluedMap<String, String> params, String prefix) {
String memberPrefix = prefix + ".member.";
return params.entrySet().stream()
.filter(entry -> entry.getKey().startsWith(memberPrefix))
.filter(entry -> entry.getKey().substring(memberPrefix.length()).matches("[1-9][0-9]*"))
.sorted(Comparator.comparingInt((Map.Entry<String, List<String>> entry) -> entry.getKey().length())
.thenComparing(Map.Entry::getKey))
.flatMap(entry -> entry.getValue().stream())
.toList();
}