Files
floci/src/test/java/io/github/hectorvent
Stuart Lang b65b7aa07f fix(sns): emit canonical error codes for Publish size violations (#906)
* fix(sns): emit correct error codes for Publish size violations

Publish was throwing AwsException with the SDK class name
"InvalidParameterException" as the error code, which the AWS SDK
unmarshaller doesn't recognise (it expects the AWS Query protocol
code "InvalidParameter"). Result: the SDK fell back to the base
AmazonSimpleNotificationServiceException instead of the typed
InvalidParameterException.

Use the canonical AWS error codes:
- body alone > 256 KiB -> "InvalidParameter" (-> InvalidParameterException)
- body + subject + attributes > 256 KiB -> "InvalidParameterValue"
  (-> InvalidParameterValueException), matching real SNS which
  blames the attribute set when the body itself fits.

* refactor(sns): avoid double UTF-8 encoding of message in publish size check

Reuse the precomputed messageBytes when calling computePublishSize so
the message body isn't encoded twice for the body-only and combined
payload checks.

* fix(sns): align both Publish size-violation branches to InvalidParameter

Review feedback on #906: validation against real AWS SNS (eu-west-1)
showed both the body-only and combined-payload overflow cases return
the same error: InvalidParameter / "Invalid parameter: Message too long".
The two-code split in the PR followed the SDK documentation but diverged
from observed wire behaviour.

Collapse to a single check using the already-computed payload size, and
drop the misleading "MessageAttributes Reason: ..." message text since
the overflow can come from any combination of body, subject, or
attributes. Update the corresponding test name and assertion.
2026-05-18 21:03:58 -05:00
..