Repository navigation
Description
Follow-up to #454.
What
#454 added message-attribute parsing to SendMessage and SendMessageBatch because AWS measures a message's size as the body plus every component of every message attribute — the developer guide is explicit: "All components of a message attribute are included in the 1 MiB message size restriction." Enforcing the limit faithfully therefore required parsing them.
They are parsed for measurement only. Substrate does not store them on the message or return them from ReceiveMessage:
SQSMessage.MessageAttributesexists on the type (emulator/sqs_types.go) but is never populated by either send path.receiveMessagehas noMessageAttributes/MessageAttributeNameshandling at all, so a consumer that sends attributes and reads them back gets nothing.
This is the batch's recurring shape in its quieter register: the call succeeds, and a later read comes back empty. A consumer routing on an attribute (messageType, a trace ID, a tenant discriminator) sees every message fall to its default branch, and their dispatch test passes while verifying nothing.
Scope
- Store parsed attributes on
SQSMessagefrom bothSendMessageandSendMessageBatch, under both protocols. - Return them from
ReceiveMessage, honoringMessageAttributeNames(including theAll/.*wildcard) — attributes are returned only when requested, so returning them unconditionally would be its own infidelity. MD5OfMessageAttributeson the send response, per the digest algorithm the developer guide specifies (sorted by name; length-prefixed name, data type, transport type byte, value).- Confirm the
ReceiveMessagewire shape for both protocols against the API reference before implementing.
Acceptance criteria
- Attributes sent under the query protocol (
MessageAttribute.N.Name/.Value.DataType/.Value.StringValue/.Value.BinaryValue) round-trip throughReceiveMessage. - Same for the JSON protocol.
-
MessageAttributeNames=Allreturns all; a named subset returns only those; omitting it returns none. - Binary attributes round-trip base64-correctly.
-
MD5OfMessageAttributesmatches the documented algorithm, verified against a known-good digest. - Batch-sent attributes round-trip too.
-
docs/services.mdrecords the behaviour.
Activity
feat(sqs): enforce MaximumMessageSize on SendMessage (#454) (#462)
fix(sqs): store and return message attributes (#461) (#465)
scttfrdmn commentedon Aug 2, 2026
Shipped in v0.85.0 (#465). Your "verified against a known-good digest" criterion is met, and the way it is met is worth reporting, because it holds with no network access — which the test suite requires.
The digest is verifiable offline
The algorithm published in the developer guide's Calculating the MD5 message digest for message attributes reproduces three captured real-AWS digests exactly. Those three vectors ship in
emulator/sqs_messageattributes_test.gowith their provenance, so the test asserts against known-good values rather than against a re-derivation of the implementation. The implementation was checked against them before any of the wiring was written, so they are a check on the code and not a transcription of it.Two details are load-bearing, and a reimplementation gets both wrong by default:
049075255ebc53fb95f7f9f3cedf3c50from the raw bytes and5ff413c9dc7bd18abea88ca05643f902from base64. This is the same raw-vs-encoded distinction SQS: SendMessage does not enforce MaximumMessageSize #454 had to make for size measurement, except here there is a hash to prove which one AWS means.Number.java.lang.Longhashes as the full 21-byte string, not the 6 bytes of itsNumberbase. Vector 2 does not reproduce without it.Also confirmed against a moto test asserting
"MD5OfMessageAttributes" not in msg: the field is omitted entirely from a response for a message with no attributes, rather than carrying the MD5 of zero bytes.Attributes are returned only for the names you ask for
Worth flagging because the permissive fix is the trap here. Returning attributes unconditionally would make a consumer's test pass while their production caller — which never sets
MessageAttributeNames— reads nothing from real SQS. All the documented selectors work:Alland.*for everything, a bare name for one, and theprefix.*form ("all message attributes starting with a prefix, for examplebar.*"). A named attribute the message does not carry is absent rather than an error.One consequence to be aware of:
MD5OfMessageAttributeson a receive is the digest of what was returned, not a replay of the send-time value. So a request naming a subset gets a digest over that subset. Replaying the stored send-time digest would fail a consumer's integrity check on any selective receive; there is a test pinning this.Coverage
Stored and returned on
SendMessage,SendMessageBatchandReceiveMessage, under both the query and JSON protocols. Binary round-trips byte-identically (base64 on the wire in both protocols; the XML path needed explicit encoding, sinceencoding/jsonbase64s a[]bytefor free andencoding/xmldoes not). Attributes survive a redelivery after the visibility timeout. A FIFO dedup hit returns the digest of this request's attributes rather than the original's, so a byte-identical retry's integrity check passes.Attribute names are emitted in sorted order. Real SQS promises no order, but a Go map iterates randomly, and one substrate response differing from the next for identical input would break the only property this emulator exists to provide.
The 10-attribute maximum is still not enforced
There is a test asserting a 10-attribute message is accepted — the boundary, per your scope note — but an 11th is accepted too. That and the documented attribute-name rules (no
AWS./Amazon.prefix, no leading/trailing or consecutive periods, the character set, the 256-character limit) are filed as #472. They are reachable now that attributes are stored, and they hit the same provenance wall #454 and this issue did: theSendMessageErrors section names none of them, so the codes have to be captured rather than guessed.chore(release): v0.85.0 (#467)
fix(sqs): warn on a stored attribute violation, still return the mess…