From a032ec5ac0a5e42224f17b819ccb0c8b82d3c332 Mon Sep 17 00:00:00 2001 From: Kenshin Okinaka Date: Sat, 13 Jun 2026 16:16:14 +0900 Subject: [PATCH] fix(ses): keep MailFromAttributes block when MAIL FROM is unconfigured (#1310) GetEmailIdentity dropped the entire MailFromAttributes block for an identity with no MAIL FROM domain configured, so an SDK caller saw mailFromAttributes() == null on the emulator but non-null on real AWS. AWS keeps the block carrying BehaviorOnMxFailure and omits only the inner MailFromDomain / MailFromDomainStatus fields. Clearing the MAIL FROM domain also resets BehaviorOnMxFailure to UseDefaultValue, matching AWS, so a cleared identity is indistinguishable from one that was never configured. --- .../floci/services/ses/SesController.java | 4 ++-- .../hectorvent/floci/services/ses/SesService.java | 4 +++- .../SesIdentityAttributesV2IntegrationTest.java | 15 ++++++++++++--- .../floci/services/ses/SesV2IntegrationTest.java | 4 +++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java index db70afa48c..55408cec5c 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java +++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java @@ -1088,12 +1088,12 @@ public class SesController { result.set("DkimAttributes", buildDkimAttributes(identity)); + ObjectNode mailFromAttributes = result.putObject("MailFromAttributes"); + mailFromAttributes.put("BehaviorOnMxFailure", v1BehaviorToV2(identity.getBehaviorOnMxFailure())); String mailFromDomain = identity.getMailFromDomain(); if (mailFromDomain != null && !mailFromDomain.isEmpty()) { - ObjectNode mailFromAttributes = result.putObject("MailFromAttributes"); mailFromAttributes.put("MailFromDomain", mailFromDomain); mailFromAttributes.put("MailFromDomainStatus", toV2Status(identity.getMailFromDomainStatus())); - mailFromAttributes.put("BehaviorOnMxFailure", v1BehaviorToV2(identity.getBehaviorOnMxFailure())); } result.putObject("Policies"); diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java index b5046c2595..1d38527952 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java +++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java @@ -474,7 +474,9 @@ public class SesService { "Identity <" + identityValue + "> does not exist.", 400)); identity.setMailFromDomain(clearing ? null : mailFromDomain); identity.setMailFromDomainStatus(clearing ? "Pending" : "Success"); - if (normalizedBehavior != null) { + if (clearing) { + identity.setBehaviorOnMxFailure("UseDefaultValue"); + } else if (normalizedBehavior != null) { identity.setBehaviorOnMxFailure(normalizedBehavior); } identityStore.put(key, identity); diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java index 8a1c24b6c7..ff7adf7618 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java @@ -32,14 +32,18 @@ class SesIdentityAttributesV2IntegrationTest { .then() .statusCode(200); - // Verify MailFromAttributes is omitted by default + // With no MAIL FROM domain configured, AWS keeps the MailFromAttributes + // block carrying only BehaviorOnMxFailure and omits the inner + // MailFromDomain / MailFromDomainStatus fields. given() .header("Authorization", AUTH_HEADER) .when() .get("/v2/email/identities/v2-attrs.floci.test") .then() .statusCode(200) - .body("MailFromAttributes", nullValue()); + .body("MailFromAttributes.BehaviorOnMxFailure", equalTo("USE_DEFAULT_VALUE")) + .body("MailFromAttributes.MailFromDomain", nullValue()) + .body("MailFromAttributes.MailFromDomainStatus", nullValue()); } @Test @@ -88,13 +92,18 @@ class SesIdentityAttributesV2IntegrationTest { .then() .statusCode(200); + // Clearing the MAIL FROM domain returns to the unconfigured shape: + // the block stays, BehaviorOnMxFailure resets to USE_DEFAULT_VALUE, + // and the inner domain / status fields drop out. given() .header("Authorization", AUTH_HEADER) .when() .get("/v2/email/identities/v2-attrs.floci.test") .then() .statusCode(200) - .body("MailFromAttributes", nullValue()); + .body("MailFromAttributes.BehaviorOnMxFailure", equalTo("USE_DEFAULT_VALUE")) + .body("MailFromAttributes.MailFromDomain", nullValue()) + .body("MailFromAttributes.MailFromDomainStatus", nullValue()); } @Test diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java index 3ba3446037..2830f08ce3 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java @@ -1189,7 +1189,9 @@ class SesV2IntegrationTest { .body("DkimAttributes", notNullValue()) .body("DkimAttributes.SigningEnabled", notNullValue()) .body("DkimAttributes.Status", notNullValue()) - .body("MailFromAttributes", nullValue()) + .body("MailFromAttributes.BehaviorOnMxFailure", equalTo("USE_DEFAULT_VALUE")) + .body("MailFromAttributes.MailFromDomain", nullValue()) + .body("MailFromAttributes.MailFromDomainStatus", nullValue()) .body("Policies", notNullValue()) .body("Tags", notNullValue()); }