feat(ses): honor ConfigurationSetName on CreateEmailIdentity (v2) (#1812)

* feat(ses): honor ConfigurationSetName on CreateEmailIdentity (v2)

CreateEmailIdentity now reads the optional ConfigurationSetName and sets it as
the identity's default configuration set, surfaced by GetEmailIdentity. Verified
against AWS: a non-existent configuration set fails with NotFoundException before
the identity is created (atomic), matching the deleted-default send behavior.

* fix(ses): treat only an empty ConfigurationSetName as absent on CreateEmailIdentity

A whitespace-only ConfigurationSetName was silently ignored (isBlank),
diverging from the PutEmailIdentityConfigurationSetAttributes path, which
routes such a name through name validation. Switch to isEmpty so both paths
reject a whitespace-only name as invalid input (400), and add coverage for
the empty (no default) and whitespace (400) cases.

* test(ses): clarify that empty-string ConfigurationSetName handling deviates from AWS

The comment on the empty-string CreateEmailIdentity test mentioned that AWS stores ""
verbatim without stating that Floci deliberately diverges (treating "" as "no default"),
which could read as if the assertion matched AWS. Reword to make the deviation and its
rationale explicit.

* docs(ses): correct the non-string ConfigurationSetName comment to match the actual response

The comment claimed AWS returns a 400 with an empty body, but the code throws a
SerializationException that AwsExceptionMapper renders as a JSON error body. Reword the
comment to describe the actual response shape.

* fix(ses): reject a non-string EmailIdentity on CreateEmailIdentity

CreateEmailIdentity read EmailIdentity via asText, which coerces a non-string JSON value
(e.g. 123 -> "123") and would silently create an identity named "123". Reject a non-string
EmailIdentity with a 400 SerializationException, matching the ConfigurationSetName handling
in the same method.

* fix(ses): validate Tags before creating the identity on CreateEmailIdentity

parseTagsArray ran after verifyEmailIdentity/verifyDomainIdentity, so a non-array Tags
value (e.g. "Tags":"oops") returned 400 but left the identity created — a half-created
state. parseTagsArray is pure, so hoist it above the create; the identity is now
persisted only after both the ConfigurationSetName and the Tags shape have been
validated, matching AWS.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-08-12 00:12:16 -04:00
1 parent b6765b3056
commit cd3588b517
3 files changed
+159 -2

No files matched your search

@@ -104,4 +104,19 @@ class SesEmailIdentityConfigurationSetTest {
.build()))
.isInstanceOf(NotFoundException.class);
}
@Test
@Order(4)
void createEmailIdentity_withConfigurationSet_readsBack() {
String id = "sdk-cs-oncreate-" + TestFixtures.uniqueName() + "@example.com";
sesV2.createEmailIdentity(CreateEmailIdentityRequest.builder()
.emailIdentity(id).configurationSetName(configSet).build());
try {
assertThat(sesV2.getEmailIdentity(GetEmailIdentityRequest.builder()
.emailIdentity(id).build()).configurationSetName())
.isEqualTo(configSet);
} finally {
sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder().emailIdentity(id).build());
}
}
}