fix(sns): carry Status on VerificationException (#5602)

VerifySMSSandboxPhoneNumber's VerificationException declares two required
members, Message and Status, and Floci sent only the message, so status() came
back null in the SDKs.

AWS documents no values for Status, and no recorded response carries one, so
Floci picks one from what the API does publish: the number's own verification
status, which a wrong password leaves Pending. Pending and Verified are the only
statuses SNS defines for a sandbox number, and the developer guide reads a
number left Pending as an unsuccessful verification. docs/services/sns.md says
the value is Floci's choice.

JSON errors already write an exception's extra members into the body. Query
errors did not: SnsQueryHandler built them from the code, message and status
alone. AwsQueryResponse gains an error overload that writes the extra members
into <Error> after <Message>, where the SDKs read them, and every SNS catch site
now passes the exception through it.

Refs #5570
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-10-13 22:28:37 -05:00
1 parent f3562af70f
commit c5a964297e
7 files changed
+137 -38

No files matched your search

@@ -38,6 +38,7 @@ import software.amazon.awssdk.services.sns.model.SetSubscriptionAttributesReques
import software.amazon.awssdk.services.sns.model.SubscribeRequest;
import software.amazon.awssdk.services.sns.model.SubscribeResponse;
import software.amazon.awssdk.services.sns.model.UnsubscribeRequest;
import software.amazon.awssdk.services.sns.model.VerificationException;
import software.amazon.awssdk.services.sns.model.VerifySmsSandboxPhoneNumberRequest;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sqs.model.*;
@@ -671,8 +672,15 @@ class SnsTest {
try {
assertThat(sandboxStatus(phoneNumber)).isEqualTo(SMSSandboxPhoneNumberVerificationStatus.PENDING);
String code = textedCode(phoneNumber);
String wrong = String.format("%06d", (Integer.parseInt(code) + 1) % 1_000_000);
assertThatThrownBy(() -> sns.verifySMSSandboxPhoneNumber(VerifySmsSandboxPhoneNumberRequest.builder()
.phoneNumber(phoneNumber).oneTimePassword(wrong).build()))
.isInstanceOfSatisfying(VerificationException.class,
e -> assertThat(e.status()).isEqualTo("Pending"));
sns.verifySMSSandboxPhoneNumber(VerifySmsSandboxPhoneNumberRequest.builder()
.phoneNumber(phoneNumber).oneTimePassword(textedCode(phoneNumber)).build());
.phoneNumber(phoneNumber).oneTimePassword(code).build());
assertThat(sandboxStatus(phoneNumber)).isEqualTo(SMSSandboxPhoneNumberVerificationStatus.VERIFIED);
} finally {