fix(cloudwatch): validate manual state reason lengths (#6470)

Check modeled reason lengths before state mutation, preserving required StateReason validation and both regression groups from current main. Use the Unicode-aware Smithy formatter.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-10-24 22:24:06 -04:00
1 parent 3d2e17bbbd
commit 75d7923290
4 files changed
+89

No files matched your search

@@ -562,6 +562,16 @@ public class CloudWatchMetricsService {
if (stateReason == null) {
throw SmithyValidationErrors.validationError(SmithyValidationErrors.notNull("stateReason"));
}
String reasonViolation = stateReason == null ? null
: SmithyValidationErrors.lengthOutOfRange("stateReason", stateReason, 0, 1023);
if (reasonViolation != null) {
throw SmithyValidationErrors.validationError(reasonViolation);
}
String dataViolation = stateReasonData == null ? null
: SmithyValidationErrors.lengthOutOfRange("stateReasonData", stateReasonData, 0, 4000);
if (dataViolation != null) {
throw SmithyValidationErrors.validationError(dataViolation);
}
List<AlarmSnsNotifier.Notification> notifications = List.of();
synchronized (this) {
String key = region + "::" + alarmName;