fix: parse S3 EventBridge notification XML (#3350)

This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-09-11 19:16:51 -04:00
1 parent 9f36a8729f
commit ad9a88cf7e
2 files changed
+131 -1

No files matched your search

@@ -1779,7 +1779,7 @@ public class S3Controller {
new LambdaNotification(parsed.id, parsed.arn, parsed.events, parsed.filterRules));
}
config.setEventBridgeEnabled(xml.contains("<EventBridgeConfiguration"));
config.setEventBridgeEnabled(parseEventBridgeConfiguration(xml));
s3Service.putBucketNotificationConfiguration(bucket, config);
return Response.ok().build();
@@ -1788,6 +1788,20 @@ public class S3Controller {
}
}
private static boolean parseEventBridgeConfiguration(String xml) {
if (!"NotificationConfiguration".equals(XmlParser.rootElementName(xml))) {
throw new AwsException("MalformedXML", "The XML you provided was not well-formed.", 400);
}
List<String> children = XmlParser.childElementNames(xml, "NotificationConfiguration");
long eventBridgeConfigurations = children.stream()
.filter("EventBridgeConfiguration"::equals)
.count();
if (eventBridgeConfigurations > 1) {
throw new AwsException("MalformedXML", "The XML you provided was not well-formed.", 400);
}
return eventBridgeConfigurations == 1;
}
private record ParsedNotificationGroup(String id, String arn, List<String> events,
List<FilterRule> filterRules) {}