From 234af69bd253c0feb981e67d74ad64519f40f5fc Mon Sep 17 00:00:00 2001 From: Kenshin Okinaka Date: Mon, 15 Jun 2026 09:25:17 +0900 Subject: [PATCH] fix(ses): omit unknown identities from GetIdentityNotificationAttributes (#1338) The handler emitted a map entry with an empty for every queried identity, including ones that were never verified. Real AWS returns an empty NotificationAttributes map for an unknown identity and drops it from a mixed query, never an entry with missing fields (verified against real AWS SES on 2026-06-13). The fabricated empty entry also violated the response contract, since the entry's value lacked the required ForwardingEnabled field. The handler now skips identities the service doesn't know about. --- .../floci/services/ses/SesQueryHandler.java | 25 ++++++------ ...esIdentityAttributesV1IntegrationTest.java | 39 +++++++++++++++++++ 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java index 678ce465e9..abadf99914 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java +++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java @@ -267,21 +267,22 @@ public class SesQueryHandler { var xml = new XmlBuilder().start("NotificationAttributes"); for (String identityValue : identities) { Identity identity = sesService.getIdentityNotificationAttributes(identityValue, region); + if (identity == null) { + continue; + } xml.start("entry"); xml.elem("key", identityValue); xml.start("value"); - if (identity != null) { - xml.elem("BounceTopic", identity.getNotificationAttributes().getOrDefault("BounceTopic", "")); - xml.elem("ComplaintTopic", identity.getNotificationAttributes().getOrDefault("ComplaintTopic", "")); - xml.elem("DeliveryTopic", identity.getNotificationAttributes().getOrDefault("DeliveryTopic", "")); - xml.elem("ForwardingEnabled", String.valueOf(identity.isFeedbackForwardingEnabled())); - xml.elem("HeadersInBounceNotificationsEnabled", - String.valueOf(identity.getHeadersInNotificationsEnabled().getOrDefault("Bounce", false))); - xml.elem("HeadersInComplaintNotificationsEnabled", - String.valueOf(identity.getHeadersInNotificationsEnabled().getOrDefault("Complaint", false))); - xml.elem("HeadersInDeliveryNotificationsEnabled", - String.valueOf(identity.getHeadersInNotificationsEnabled().getOrDefault("Delivery", false))); - } + xml.elem("BounceTopic", identity.getNotificationAttributes().getOrDefault("BounceTopic", "")); + xml.elem("ComplaintTopic", identity.getNotificationAttributes().getOrDefault("ComplaintTopic", "")); + xml.elem("DeliveryTopic", identity.getNotificationAttributes().getOrDefault("DeliveryTopic", "")); + xml.elem("ForwardingEnabled", String.valueOf(identity.isFeedbackForwardingEnabled())); + xml.elem("HeadersInBounceNotificationsEnabled", + String.valueOf(identity.getHeadersInNotificationsEnabled().getOrDefault("Bounce", false))); + xml.elem("HeadersInComplaintNotificationsEnabled", + String.valueOf(identity.getHeadersInNotificationsEnabled().getOrDefault("Complaint", false))); + xml.elem("HeadersInDeliveryNotificationsEnabled", + String.valueOf(identity.getHeadersInNotificationsEnabled().getOrDefault("Delivery", false))); xml.end("value"); xml.end("entry"); } diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV1IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV1IntegrationTest.java index 9c711cc80a..595b6510d9 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV1IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV1IntegrationTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.TestMethodOrder; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.not; @QuarkusTest @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @@ -327,4 +328,42 @@ class SesIdentityAttributesV1IntegrationTest { .body(containsString("false")) .body(containsString("false")); } + + @Test + @Order(22) + void getIdentityNotificationAttributes_unknownIdentity_omittedFromMap() { + // Real AWS returns an empty NotificationAttributes map for an identity + // that doesn't exist, rather than an entry with empty values + // (verified against real AWS SES on 2026-06-13). + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "GetIdentityNotificationAttributes") + .formParam("Identities.member.1", "ghost-notif.floci.test") + .when() + .post("/") + .then() + .statusCode(200) + .body(containsString("GetIdentityNotificationAttributesResponse")) + .body(containsString("")) + .body(not(containsString("ghost-notif.floci.test"))); + } + + @Test + @Order(23) + void getIdentityNotificationAttributes_mixedKnownAndUnknown_returnsOnlyKnown() { + // The unknown identity is dropped from the map; the known one stays. + given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", AUTH) + .formParam("Action", "GetIdentityNotificationAttributes") + .formParam("Identities.member.1", "v1-attrs.floci.test") + .formParam("Identities.member.2", "ghost-notif2.floci.test") + .when() + .post("/") + .then() + .statusCode(200) + .body(containsString("v1-attrs.floci.test")) + .body(not(containsString("ghost-notif2.floci.test"))); + } }