Light, fluffy, and always free - The AWS Local Emulator alternative
fix(ses): answer invalid v1 bulk destination entries on their own (#6742)
Kenshin Okinakaafdd4b46ec50
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesTemplateTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesTemplateTest.javaindex 34a964fdc4..7ad918a8ab 100644--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesTemplateTest.java+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/SesTemplateTest.java@@ -577,6 +577,7 @@ class SesTemplateTest {assertThatThrownBy(() -> sesV1.sendBulkTemplatedEmail(SendBulkTemplatedEmailRequest.builder().source(v1Sender).template("sdk-v1-bulk-missing-" + System.currentTimeMillis())+ .defaultTemplateData("{}").destinations(BulkEmailDestination.builder().destination(d -> d.toAddresses("[email protected]")).build())diff --git a/docs/services/ses.md b/docs/services/ses.mdindex cea7a6d09e..8cd5e73cdd 100644--- a/docs/services/ses.md+++ b/docs/services/ses.md@@ -304,7 +304,7 @@ curl $AWS_ENDPOINT_URL/_aws/ses- An email address identity is verified as soon as it is created; no inbox verification flow is required. A domain identity stays `Pending` until its DKIM CNAME records exist in a Route 53 hosted zone in Floci, then becomes `Success`.- `SendEmail`, `SendRawEmail`, `SendTemplatedEmail` and `SendBulkTemplatedEmail`, and v2 `SendEmail` and `SendBulkEmail`, require verified senders, as on AWS ([SendEmail](https://docs.aws.amazon.com/ses/latest/APIReference/API_SendEmail.html), [Email sending errors](https://docs.aws.amazon.com/ses/latest/dg/troubleshoot-error-messages.html)): each address used as a "From", "Source", "Sender" or "Return-Path" address must be a verified email address identity or an address in a verified domain identity or one of its subdomains. That is the `Source` or `FromEmailAddress` and the `ReturnPath` or `FeedbackForwardingEmailAddress`, plus, on a raw message, every mailbox of its `From` header, its `Sender` and its `Return-Path` header. A v2 raw send reads the `From` header only in place of a missing `FromEmailAddress` and accepts any `From` header when one is given (probe-confirmed), so the header is checked only then. Every other address present is checked; whether AWS still checks a `Return-Path` header that the request's return path overrides has not been probed. One `MessageRejected` lists every unverified address ("Email address is not verified. The following identities failed the check in region US-EAST-1: [email protected], [email protected]") and nothing is captured or relayed. An address covered by a sending-authorization ARN of another account (`SourceArn`, `FromArn`, `ReturnPathArn`, their `X-SES-*-ARN` headers, or v2 `FromEmailAddressIdentityArn` and `FeedbackForwardingEmailAddressIdentityArn`) is not checked, since it is the owner's identity; on a raw send the source ARN also covers the `From` and return-path addresses that have no ARN of their own. A bulk send checks its sender and return path once and rejects the whole call; when no entry has a recipient it checks neither and every entry fails on its own (probe-confirmed on v2 `SendBulkEmail` and v1 `SendBulkTemplatedEmail`). On v2 `SendEmail` and `SendBulkEmail`, and v1 `SendTemplatedEmail` and `SendBulkTemplatedEmail`, an unknown configuration set is reported before the check and an unknown stored template only after it (probe-confirmed). The verification codes and invitations Cognito sends are not affected.-- `SendBulkTemplatedEmail` reads every `Destinations.member.N` up to the highest N. A missing `Template` (with no `TemplateArn`), missing `Destinations`, and an entry without a `Destination` or a skipped N are model violations, answered together as one 400 `ValidationError` ("2 validation errors detected: Value at 'template' failed to satisfy constraint: Member must not be null; Value at 'destinations.2.member.destination' failed to satisfy constraint: Member must not be null") ahead of every other check of the request, the address syntax and the destination count included (probe-confirmed). Floci lists the skipped entries of the first 1000 indexes only; a higher index fails the destination count. On both bulk sends an entry whose address lists are empty answers "Missing required header 'To'." on its own when another entry has a recipient, and when none has one every entry answers "Destination cannot be empty" (probe-confirmed).+- `SendBulkTemplatedEmail` reads every `Destinations.member.N` up to the highest N. A missing `Template` (with no `TemplateArn`), missing `Destinations`, and an entry without a `Destination` or a skipped N are model violations, answered together as one 400 `ValidationError` ("2 validation errors detected: Value at 'template' failed to satisfy constraint: Member must not be null; Value at 'destinations.2.member.destination' failed to satisfy constraint: Member must not be null") ahead of every other check of the request, the address syntax and the destination count included (probe-confirmed). Floci lists the skipped entries of the first 1000 indexes only; a higher index fails the destination count. On both bulk sends an entry whose address lists are empty answers "Missing required header 'To'." on its own when another entry has a recipient, and when none has one every entry answers "Destination cannot be empty" (probe-confirmed). A `DefaultTags` or `ReplacementTags` tag without a `Name` or a `Value` is a model violation too, a skipped tag index listing both, and the top-level members are listed ahead of the nested ones ('template' before 'defaultTags.1.member.name'). A missing or empty `DefaultTemplateData` is a 400 `InvalidParameterValue` ("The default template data does not exist"), answered after the `Source` syntax and the destination count and before the template lookup and the sender verification (probe-confirmed). On `SendBulkTemplatedEmail` an entry with more than 50 recipients ("Recipient count exceeds 50."), template data that is not a JSON object ("The template data is invalid") or a tag with an empty name ("The tag name must be specified.") fails on its own with `InvalidParameterValue`. Invalid `DefaultTemplateData` or an empty `DefaultTags` name fails every entry, and within one entry an address syntax error wins over an empty tag name, which wins over invalid template data, which wins over the recipient count (probe-confirmed). v2 `SendBulkEmail` still rejects the whole call for more than 50 recipients in a destination (not probed).- `SendEmail` stores the text body or the HTML body as the captured message body.- `SetIdentityNotificationTopic` publishes to the configured topic on a Bounce/Complaint/Delivery event (triggered via the mailbox simulator addresses or the suppression list), independent of any configuration set. The payload uses the legacy format (`notificationType`, no `mail.tags`, headers only when `SetIdentityHeadersInNotificationsEnabled` is on).- Identity (sending authorization) policies are stored and returned as metadata: the policy document, the per-identity limit of 20, and the create/update/delete error shapes match AWS, but Floci does not evaluate policy authorization (Principal-account existence, Resource-ARN match) or gate sending on it. A send naming another account's identity ARN skips the verified-sender check for the addresses it covers, without looking that identity up or reading its policy.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.javaindex 838b22b009..16b48417fc 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@@ -773,8 +773,9 @@ public class SesQueryHandler {String templateName = getParam(params, "Template");String templateArn = getParam(params, "TemplateArn");BulkDestinationIndexes destinations = bulkDestinationIndexes(params);- // The model validation answers ahead of every other check of the request, listing its- // violations in the model's member order (probe-confirmed).+ // The model validation answers ahead of every other check of the request. It lists the+ // top-level members before the nested ones ('template' ahead of 'defaultTags.1.member.name'),+ // each group in the model's member order (probe-confirmed).List<String> violations = new ArrayList<>();if (templateName == null && templateArn == null) {violations.add(SmithyValidationErrors.notNullWithoutValue("template"));@@ -782,12 +783,15 @@ public class SesQueryHandler {if (!params.containsKey("Destinations") && !hasParamWithPrefix(params, "Destinations.")) {violations.add(SmithyValidationErrors.notNullWithoutValue("destinations"));}+ addMessageTagViolations(params, "DefaultTags", "defaultTags", violations);// A skipped index, like an entry without a Destination, is a null destination// (probe-confirmed). An empty address list still sends its bare key.for (int i = 1; i <= Math.min(destinations.last(), MAX_VALIDATED_DESTINATION_INDEX); i++) {if (!destinations.withDestination().contains(i)) {violations.add(SmithyValidationErrors.notNullWithoutValue("destinations." + i + ".member.destination"));}+ addMessageTagViolations(params, "Destinations.member." + i + ".ReplacementTags",+ "destinations." + i + ".member.replacementTags", violations);}if (!violations.isEmpty()) {throw SmithyValidationErrors.validationError(violations);@@ -815,22 +819,40 @@ public class SesQueryHandler {// AWS counts the destinations before it looks the template up (probe-confirmed). The list// runs to its highest index, so counting that index first also bounds the scan below.SesService.requireBulkDestinationCount(lastIndex);+ // Probe-confirmed for an absent and an empty value; where it falls among the checks above+ // is unprobed.+ if (defaultDataRaw == null || defaultDataRaw.isEmpty()) {+ throw new AwsException("InvalidParameterValue", "The default template data does not exist", 400);+ }+ JsonNode defaultTemplateData = templateDataObject(defaultDataRaw);+ List<MessageTag> defaultEmailTags = readMessageTags(params, "DefaultTags");List<BulkEmailEntry> entries = new ArrayList<>();for (int i = 1; i <= lastIndex; i++) {String destPrefix = "Destinations.member." + i;List<String> to = extractMembers(params, destPrefix + ".Destination.ToAddresses");List<String> cc = extractMembers(params, destPrefix + ".Destination.CcAddresses");List<String> bcc = extractMembers(params, destPrefix + ".Destination.BccAddresses");- String replacementRaw = getParam(params, destPrefix + ".ReplacementTemplateData");- List<MessageTag> replacementTags = extractMessageTags(params, destPrefix + ".ReplacementTags");+ JsonNode replacementData = templateDataObject(getParam(params, destPrefix + ".ReplacementTemplateData"));+ List<MessageTag> replacementTags = readMessageTags(params, destPrefix + ".ReplacementTags");+ // Each of these fails its own entry, with a 200 for the call; invalid default data or a+ // blank default tag name fails every entry. A blank tag name wins over invalid data and+ // an address syntax error over both (probe-confirmed).+ String rejection = null;+ if (hasBlankName(defaultEmailTags) || hasBlankName(replacementTags)) {+ rejection = "The tag name must be specified.";+ } else if (defaultTemplateData == null || replacementData == null) {+ rejection = "The template data is invalid";+ }entries.add(new BulkEmailEntry(to, cc, bcc,- parseTemplateData(replacementRaw), replacementTags, List.of()));+ replacementData == null ? objectMapper.createObjectNode() : replacementData,+ replacementTags, List.of(), rejection));+ }+ if (defaultTemplateData == null) {+ defaultTemplateData = objectMapper.createObjectNode();}- JsonNode defaultTemplateData = parseTemplateData(defaultDataRaw);String configurationSetName = getParam(params, "ConfigurationSetName");String returnPath = getParam(params, "ReturnPath");- List<MessageTag> defaultEmailTags = extractMessageTags(params, "DefaultTags");List<BulkEmailEntryResult> results = sesService.sendBulkEmail(SendBulkEmailRequest.builder().source(source).sourceArn(getParam(params, "SourceArn"))@@ -840,6 +862,7 @@ public class SesQueryHandler {.configurationSetName(configurationSetName).defaultEmailTags(defaultEmailTags).region(region)+ .recipientLimitPerEntry(true).defaultContent(new EmailContent.Template(resolvedName, defaultTemplateData, List.of())).entries(entries).build());@@ -1581,8 +1604,52 @@ public class SesQueryHandler {return node;}+ // null for data that is not a JSON object, which a bulk send answers per entry.+ private JsonNode templateDataObject(String raw) {+ if (raw == null || raw.isBlank()) {+ return objectMapper.createObjectNode();+ }+ try {+ JsonNode node = objectMapper.readTree(raw);+ return node.isObject() ? node : null;+ } catch (JsonProcessingException expected) {+ // Malformed JSON is the same per-entry failure as a non-object value.+ return null;+ }+ }+// --- Helpers ---+ // A skipped index is a tag with neither member, so it lists both (probe-confirmed).+ private static void addMessageTagViolations(MultivaluedMap<String, String> params, String prefix,+ String path, List<String> violations) {+ int last = Math.min(lastMemberIndex(params, prefix + ".member."), MAX_VALIDATED_TAG_INDEX);+ for (int i = 1; i <= last; i++) {+ if (params.getFirst(prefix + ".member." + i + ".Name") == null) {+ violations.add(SmithyValidationErrors.notNullWithoutValue(path + "." + i + ".member.name"));+ }+ if (params.getFirst(prefix + ".member." + i + ".Value") == null) {+ violations.add(SmithyValidationErrors.notNullWithoutValue(path + "." + i + ".member.value"));+ }+ }+ }++ private static int lastMemberIndex(MultivaluedMap<String, String> params, String prefix) {+ int last = 0;+ for (String key : params.keySet()) {+ if (key.startsWith(prefix)) {+ int dot = key.indexOf('.', prefix.length());+ last = Math.max(last, memberIndex(+ dot < 0 ? key.substring(prefix.length()) : key.substring(prefix.length(), dot)));+ }+ }+ return last;+ }++ private static boolean hasBlankName(List<MessageTag> tags) {+ return tags.stream().anyMatch(tag -> tag.name() == null || tag.name().isBlank());+ }+private static boolean hasParamWithPrefix(MultivaluedMap<String, String> params, String prefix) {return params.keySet().stream().anyMatch(key -> key.startsWith(prefix));}@@ -1591,6 +1658,9 @@ public class SesQueryHandler {// destination count. Where AWS stops listing null destinations has not been probed.private static final int MAX_VALIDATED_DESTINATION_INDEX = 1000;+ // Bounds the violation list in the same way; a tag past it is read only up to the first gap.+ private static final int MAX_VALIDATED_TAG_INDEX = 1000;+/** The highest {@code Destinations.member.N}, and the Ns that carry a {@code Destination}. */private record BulkDestinationIndexes(int last, Set<Integer> withDestination) {}@@ -1639,18 +1709,24 @@ public class SesQueryHandler {* no members are present.*/private List<MessageTag> extractMessageTags(MultivaluedMap<String, String> params, String prefix) {+ List<MessageTag> tags = readMessageTags(params, prefix);+ if (hasBlankName(tags)) {+ throw new AwsException("InvalidParameterValue",+ "The tag name must be specified.", 400);+ }+ return tags;+ }++ private List<MessageTag> readMessageTags(MultivaluedMap<String, String> params, String prefix) {List<MessageTag> tags = new ArrayList<>();for (int i = 1; ; i++) {String name = getParam(params, prefix + ".member." + i + ".Name");String value = getParam(params, prefix + ".member." + i + ".Value");- if (name == null && value == null) break;- if (name == null || name.isBlank()) {- throw new AwsException("InvalidParameterValue",- "The tag name must be specified.", 400);+ if (name == null && value == null) {+ return tags;}tags.add(new MessageTag(name, value));}- return tags;}private String getParam(MultivaluedMap<String, String> params, String name) {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.javaindex 124dd5bff9..fe7f6b9d91 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@@ -1700,14 +1700,14 @@ public class SesService {? requireSendingTenant(request.tenantName(), request.region(), null, () -> null): null;configSetService.validateForSending(request.configurationSetName(), request.region());- for (BulkEmailEntry entry : request.entries()) {- int recipientCount = sizeOf(entry.toAddresses())- + sizeOf(entry.ccAddresses())- + sizeOf(entry.bccAddresses());- if (recipientCount > MAX_RECIPIENTS_PER_DESTINATION) {- throw new AwsException("MessageRejected",- "Recipient count (" + recipientCount + ") in a destination exceeds the maximum of "- + MAX_RECIPIENTS_PER_DESTINATION + ".", 400);+ if (!request.recipientLimitPerEntry()) {+ for (BulkEmailEntry entry : request.entries()) {+ int recipientCount = recipientCount(entry);+ if (recipientCount > MAX_RECIPIENTS_PER_DESTINATION) {+ throw new AwsException("MessageRejected",+ "Recipient count (" + recipientCount + ") in a destination exceeds the maximum of "+ + MAX_RECIPIENTS_PER_DESTINATION + ".", 400);+ }}}@@ -1734,7 +1734,15 @@ public class SesService {List<BulkEmailEntryResult> results = new ArrayList<>(request.entries().size());for (BulkEmailEntry entry : request.entries()) {try {+ // An address syntax error wins over the entry's other failures (probe-confirmed on v1).SesAddressSyntax.requireBulkDestination(entry, request.replyToAddresses());+ if (entry.rejection() != null) {+ throw new AwsException("InvalidParameterValue", entry.rejection(), 400);+ }+ if (request.recipientLimitPerEntry() && recipientCount(entry) > MAX_RECIPIENTS_PER_DESTINATION) {+ throw new AwsException("InvalidParameterValue",+ "Recipient count exceeds " + MAX_RECIPIENTS_PER_DESTINATION + ".", 400);+ }// An entry with no recipient beside entries with one fails on its own (probe-confirmed// on v1 and v2).if (!anyBulkRecipient(List.of(entry))) {@@ -1802,6 +1810,10 @@ public class SesService {return emailTags == null ? List.of() : emailTags;}+ private static int recipientCount(BulkEmailEntry entry) {+ return sizeOf(entry.toAddresses()) + sizeOf(entry.ccAddresses()) + sizeOf(entry.bccAddresses());+ }+private static int sizeOf(List<?> list) {return list == null ? 0 : list.size();}diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/model/BulkEmailEntry.java b/src/main/java/io/github/hectorvent/floci/services/ses/model/BulkEmailEntry.javaindex e6d9c67bcc..4db0f0b1ff 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/model/BulkEmailEntry.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/model/BulkEmailEntry.java@@ -5,6 +5,10 @@ import io.quarkus.runtime.annotations.RegisterForReflection;import java.util.List;+/**+ * One destination of a bulk send. A non-null {@code rejection} is the {@code InvalidParameterValue}+ * message the caller already found for this entry; the send answers the entry with it alone.+ */@RegisterForReflectionpublic record BulkEmailEntry(List<String> toAddresses,@@ -12,5 +16,14 @@ public record BulkEmailEntry(List<String> bccAddresses,JsonNode replacementTemplateData,List<MessageTag> replacementEmailTags,- List<MessageHeader> replacementHeaders-) {}+ List<MessageHeader> replacementHeaders,+ String rejection+) {++ public BulkEmailEntry(List<String> toAddresses, List<String> ccAddresses, List<String> bccAddresses,+ JsonNode replacementTemplateData, List<MessageTag> replacementEmailTags,+ List<MessageHeader> replacementHeaders) {+ this(toAddresses, ccAddresses, bccAddresses, replacementTemplateData, replacementEmailTags,+ replacementHeaders, null);+ }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/model/SendBulkEmailRequest.java b/src/main/java/io/github/hectorvent/floci/services/ses/model/SendBulkEmailRequest.javaindex 15065a22a9..256d793cb0 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/model/SendBulkEmailRequest.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/model/SendBulkEmailRequest.java@@ -9,7 +9,9 @@ import java.util.Objects;* default content is a stored {@link EmailContent.Template}, which the send resolves only after its* sender checks, or an {@link EmailContent.InlineTemplate}; its data and headers are the defaults* each entry's replacements merge over. {@code sourceArn} and {@code returnPathArn} are the- * sending-authorization identity ARNs of the sender and the return path.+ * sending-authorization identity ARNs of the sender and the return path. With+ * {@code recipientLimitPerEntry} an entry over the recipient limit fails on its own, as on v1+ * (probe-confirmed); without it the whole call is rejected.*/public record SendBulkEmailRequest(String source,@@ -21,6 +23,7 @@ public record SendBulkEmailRequest(List<MessageTag> defaultEmailTags,String tenantName,String region,+ boolean recipientLimitPerEntry,EmailContent.TemplateContent defaultContent,List<BulkEmailEntry> entries) {@@ -49,6 +52,7 @@ public record SendBulkEmailRequest(private List<MessageTag> defaultEmailTags = List.of();private String tenantName;private String region;+ private boolean recipientLimitPerEntry;private EmailContent.TemplateContent defaultContent;private List<BulkEmailEntry> entries = List.of();@@ -64,12 +68,14 @@ public record SendBulkEmailRequest(public Builder defaultEmailTags(List<MessageTag> defaultEmailTags) { this.defaultEmailTags = defaultEmailTags; return this; }public Builder tenantName(String tenantName) { this.tenantName = tenantName; return this; }public Builder region(String region) { this.region = region; return this; }+ public Builder recipientLimitPerEntry(boolean recipientLimitPerEntry) { this.recipientLimitPerEntry = recipientLimitPerEntry; return this; }public Builder defaultContent(EmailContent.TemplateContent defaultContent) { this.defaultContent = defaultContent; return this; }public Builder entries(List<BulkEmailEntry> entries) { this.entries = entries; return this; }public SendBulkEmailRequest build() {return new SendBulkEmailRequest(source, sourceArn, replyToAddresses, returnPath, returnPathArn,- configurationSetName, defaultEmailTags, tenantName, region, defaultContent, entries);+ configurationSetName, defaultEmailTags, tenantName, region, recipientLimitPerEntry, defaultContent,+ entries);}}}diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV1IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV1IntegrationTest.javaindex 1810c8e9f1..c980ee72ff 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV1IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesBulkV1IntegrationTest.java@@ -18,6 +18,7 @@ import java.util.regex.Matcher;import java.util.regex.Pattern;import java.util.stream.Stream;+import static io.github.hectorvent.floci.core.common.SmithyValidationErrors.notNullWithoutValue;import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.containsString;import static org.hamcrest.Matchers.equalTo;@@ -42,6 +43,10 @@ class SesBulkV1IntegrationTest {private static final String MISSING_DESTINATION_2 = "1 validation error detected: Value at "+ "'destinations.2.member.destination' failed to satisfy constraint: Member must not be null";+ private static final String MEMBERS = "SendBulkTemplatedEmailResponse.SendBulkTemplatedEmailResult.Status.member";++ private static final String FULL_TEMPLATE_DATA = "{\"name\":\"X\",\"team\":\"floci\"}";+private static final Pattern MESSAGE_ID_PATTERN =Pattern.compile("<MessageId>([^<]+)</MessageId>");@@ -133,6 +138,7 @@ class SesBulkV1IntegrationTest {.formParam("Action", "SendBulkTemplatedEmail").formParam("Source", SENDER).formParam("Template", "ghost")+ .formParam("DefaultTemplateData", "{}").formParam("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]").when().post("/")@@ -280,57 +286,196 @@ class SesBulkV1IntegrationTest {"expected per-entry Status=InvalidParameterValue for missing rendering variable");}+ // Each of these fails its own entry with a 200 for the call (probed 2026-10-25).@ParameterizedTest(name = "{0}")- @MethodSource("nonObjectBulkTemplateDataPayloads")+ @MethodSource("invalidReplacementTemplateData")@Order(10)- void sendBulkTemplatedEmail_nonObjectTemplateData_returnsInvalidParameterValue(- String label, String defaultTemplateData, String replacementTemplateData) {- RequestSpecification spec = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", AUTH)- .formParam("Action", "SendBulkTemplatedEmail")- .formParam("Source", SENDER)- .formParam("Template", "v1-bulk-welcome")- .formParam("DefaultTemplateData", defaultTemplateData)- .formParam("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]");- if (replacementTemplateData != null) {- spec = spec.formParam("Destinations.member.1.ReplacementTemplateData", replacementTemplateData);- }- spec+ void sendBulkTemplatedEmail_invalidReplacementTemplateData_failsOnlyThatEntry(String label, String data) {+ bulkSpec(FULL_TEMPLATE_DATA)+ .formParam("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]")+ .formParam("Destinations.member.1.ReplacementTemplateData", data)+ .formParam("Destinations.member.2.Destination.ToAddresses.member.1", "[email protected]").when().post("/").then()- .statusCode(400)- .body(containsString("<Code>InvalidParameterValue</Code>"));+ .statusCode(200)+ .body(MEMBERS + ".size()", equalTo(2))+ .body(MEMBERS + "[0].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[0].Error", equalTo("The template data is invalid"))+ .body(MEMBERS + "[1].Status", equalTo("Success"));}- static Stream<Arguments> nonObjectBulkTemplateDataPayloads() {+ static Stream<Arguments> invalidReplacementTemplateData() {return Stream.of(- Arguments.of("array DefaultTemplateData", "[1,2,3]", null),- Arguments.of("scalar ReplacementTemplateData", "{\"team\":\"floci\"}", "42")- );+ Arguments.of("malformed JSON", "{not json"),+ Arguments.of("scalar", "42"));+ }++ @Test+ @Order(11)+ void sendBulkTemplatedEmail_invalidDefaultTemplateData_failsEveryEntry() {+ bulkSpec("[1,2,3]")+ .formParam("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]")+ .formParam("Destinations.member.1.ReplacementTemplateData", FULL_TEMPLATE_DATA)+ .formParam("Destinations.member.2.Destination.ToAddresses.member.1", "[email protected]")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(MEMBERS + ".size()", equalTo(2))+ .body(MEMBERS + "[0].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[0].Error", equalTo("The template data is invalid"))+ .body(MEMBERS + "[1].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[1].Error", equalTo("The template data is invalid"));}@Test@Order(9)- void sendBulkTemplatedEmail_recipientsExceeds50_returnsMessageRejected() {- RequestSpecification spec = given()- .contentType("application/x-www-form-urlencoded")- .header("Authorization", AUTH)- .formParam("Action", "SendBulkTemplatedEmail")- .formParam("Source", SENDER)- .formParam("Template", "v1-bulk-welcome");+ void sendBulkTemplatedEmail_recipientsExceed50_failsOnlyThatEntry() {+ RequestSpecification spec = bulkSpec(FULL_TEMPLATE_DATA);for (int i = 1; i <= 51; i++) {spec = spec.formParam("Destinations.member.1.Destination.ToAddresses.member." + i,"user" + i + "@example.com");}+ spec+ .formParam("Destinations.member.2.Destination.ToAddresses.member.1", "[email protected]")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(MEMBERS + ".size()", equalTo(2))+ .body(MEMBERS + "[0].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[0].Error", equalTo("Recipient count exceeds 50."))+ .body(MEMBERS + "[1].Status", equalTo("Success"));+ }++ @Test+ @Order(18)+ void sendBulkTemplatedEmail_emptyReplacementTagName_failsOnlyThatEntry() {+ bulkSpec(FULL_TEMPLATE_DATA)+ .formParam("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]")+ .formParam("Destinations.member.1.ReplacementTags.member.1.Name", "")+ .formParam("Destinations.member.1.ReplacementTags.member.1.Value", "v")+ .formParam("Destinations.member.2.Destination.ToAddresses.member.1", "[email protected]")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(MEMBERS + ".size()", equalTo(2))+ .body(MEMBERS + "[0].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[0].Error", equalTo("The tag name must be specified."))+ .body(MEMBERS + "[1].Status", equalTo("Success"));+ }++ @Test+ @Order(19)+ void sendBulkTemplatedEmail_emptyDefaultTagName_failsEveryEntry() {+ bulkSpec(FULL_TEMPLATE_DATA)+ .formParam("DefaultTags.member.1.Name", "")+ .formParam("DefaultTags.member.1.Value", "v")+ .formParam("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]")+ .formParam("Destinations.member.2.Destination.ToAddresses.member.1", "[email protected]")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(MEMBERS + ".size()", equalTo(2))+ .body(MEMBERS + "[0].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[0].Error", equalTo("The tag name must be specified."))+ .body(MEMBERS + "[1].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[1].Error", equalTo("The tag name must be specified."));+ }++ // Answered before the template lookup and the sender verification (probed 2026-10-27).+ @ParameterizedTest(name = "{0}")+ @MethodSource("missingDefaultTemplateData")+ @Order(20)+ void sendBulkTemplatedEmail_missingDefaultTemplateData_rejectsTheCall(String label, String data, String source,+ String template) {+ RequestSpecification spec = given()+ .contentType("application/x-www-form-urlencoded")+ .header("Authorization", AUTH)+ .formParam("Action", "SendBulkTemplatedEmail")+ .formParam("Source", source)+ .formParam("Template", template)+ .formParam("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]");+ if (data != null) {+ spec = spec.formParam("DefaultTemplateData", data);+ }spec.when().post("/").then().statusCode(400)- .body(containsString("<Code>MessageRejected</Code>"));+ .body("ErrorResponse.Error.Code", equalTo("InvalidParameterValue"))+ .body("ErrorResponse.Error.Message", equalTo("The default template data does not exist"));+ }++ static Stream<Arguments> missingDefaultTemplateData() {+ return Stream.of(+ Arguments.of("absent", null, SENDER, "v1-bulk-welcome"),+ Arguments.of("empty", "", SENDER, "v1-bulk-welcome"),+ Arguments.of("absent, unknown template", null, SENDER, "v1-bulk-missing"),+ Arguments.of("absent, unverified Source", null, "[email protected]", "v1-bulk-welcome"));+ }++ // An address syntax error wins over a blank tag name, which wins over invalid template data, which+ // wins over the recipient count (probed 2026-10-26 and 2026-10-27).+ @ParameterizedTest(name = "{0}")+ @MethodSource("entriesWithSeveralFailures")+ @Order(21)+ void sendBulkTemplatedEmail_entryWithSeveralFailures_answersTheFirst(String label, Map<String, String> entry,+ String error) {+ bulkSpec(FULL_TEMPLATE_DATA)+ .formParams(entry)+ .formParam("Destinations.member.2.Destination.ToAddresses.member.1", "[email protected]")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(MEMBERS + ".size()", equalTo(2))+ .body(MEMBERS + "[0].Status", equalTo("InvalidParameterValue"))+ .body(MEMBERS + "[0].Error", equalTo(error))+ .body(MEMBERS + "[1].Status", equalTo("Success"));+ }++ static Stream<Arguments> entriesWithSeveralFailures() {+ return Stream.of(+ Arguments.of("51 recipients, data 42 and an empty tag name",+ with(recipients(51, null),+ "Destinations.member.1.ReplacementTemplateData", "42",+ "Destinations.member.1.ReplacementTags.member.1.Name", "",+ "Destinations.member.1.ReplacementTags.member.1.Value", "v"),+ "The tag name must be specified."),+ Arguments.of("51 recipients and data 42",+ with(recipients(51, null), "Destinations.member.1.ReplacementTemplateData", "42"),+ "The template data is invalid"),+ Arguments.of("51 recipients, one malformed", recipients(51, "not-an-address"),+ "Missing final '@domain'"),+ Arguments.of("data 42 and a malformed recipient",+ with(recipients(1, "not-an-address"), "Destinations.member.1.ReplacementTemplateData", "42"),+ "Missing final '@domain'"));+ }++ // The first entry's To list of count addresses, the last one replaced by last when given.+ private static Map<String, String> recipients(int count, String last) {+ Map<String, String> params = new HashMap<>();+ for (int i = 1; i <= count; i++) {+ params.put("Destinations.member.1.Destination.ToAddresses.member." + i,+ i == count && last != null ? last : "user" + i + "@example.com");+ }+ return params;+ }++ private static RequestSpecification bulkSpec(String defaultTemplateData) {+ return given()+ .contentType("application/x-www-form-urlencoded")+ .header("Authorization", AUTH)+ .formParam("Action", "SendBulkTemplatedEmail")+ .formParam("Source", SENDER)+ .formParam("Template", "v1-bulk-welcome")+ .formParam("DefaultTemplateData", defaultTemplateData);}@Test@@ -452,6 +597,11 @@ class SesBulkV1IntegrationTest {Map<String, String> withoutDestination2 = Map.of("Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]","Destinations.member.2.ReplacementTemplateData", "{}");+ Map<String, String> oneRecipient = Map.of(+ "Source", SENDER,+ "Template", "v1-bulk-welcome",+ "DefaultTemplateData", FULL_TEMPLATE_DATA,+ "Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]");Map<String, String> gapAt2 = new HashMap<>();for (int i = 1; i <= 51; i++) {if (i != 2) {@@ -468,7 +618,35 @@ class SesBulkV1IntegrationTest {+ "Member must not be null; Value at 'destinations.2.member.destination' "+ "failed to satisfy constraint: Member must not be null"),Arguments.of("51 indexes with a gap", with(gapAt2, "Source", SENDER, "Template", "v1-bulk-welcome"),- MISSING_DESTINATION_2));+ MISSING_DESTINATION_2),+ Arguments.of("replacement tag without Name",+ with(oneRecipient, "Destinations.member.1.ReplacementTags.member.1.Value", "v"),+ "1 validation error detected: "+ + notNullWithoutValue("destinations.1.member.replacementTags.1.member.name")),+ // Probed 2026-10-26 from here on.+ Arguments.of("replacement tag without Value",+ with(oneRecipient, "Destinations.member.1.ReplacementTags.member.1.Name", "a"),+ "1 validation error detected: "+ + notNullWithoutValue("destinations.1.member.replacementTags.1.member.value")),+ Arguments.of("default tag without Name", with(oneRecipient, "DefaultTags.member.1.Value", "v"),+ "1 validation error detected: " + notNullWithoutValue("defaultTags.1.member.name")),+ // 'template' comes first although DefaultTags precedes Template in the model.+ Arguments.of("no Template and a default tag without Name", Map.of(+ "Source", SENDER,+ "Destinations.member.1.Destination.ToAddresses.member.1", "[email protected]",+ "DefaultTags.member.1.Value", "v"),+ "2 validation errors detected: " + notNullWithoutValue("template") + "; "+ + notNullWithoutValue("defaultTags.1.member.name")),+ Arguments.of("replacement tag at index 2 only", with(oneRecipient,+ "Destinations.member.1.ReplacementTags.member.2.Name", "a",+ "Destinations.member.1.ReplacementTags.member.2.Value", "v"),+ "2 validation errors detected: "+ + notNullWithoutValue("destinations.1.member.replacementTags.1.member.name") + "; "+ + notNullWithoutValue("destinations.1.member.replacementTags.1.member.value")),+ Arguments.of("default tag at index 2 only", with(oneRecipient,+ "DefaultTags.member.2.Name", "a", "DefaultTags.member.2.Value", "v"),+ "2 validation errors detected: " + notNullWithoutValue("defaultTags.1.member.name") + "; "+ + notNullWithoutValue("defaultTags.1.member.value")));}private static Map<String, String> with(Map<String, String> params, String... namesAndValues) {