Repository navigation
Description
What
No length check exists against a queue's MaximumMessageSize attribute, or against any constant, anywhere in the SendMessage path. A body larger than the queue's limit is accepted and delivered.
Real SQS rejects it. Per the SendMessage reference the error is:
InvalidParameterValue (or InvalidMessageContents / oversized-message error — confirm the exact code against the current API reference before implementing)
So a consumer's too-large-payload branch — chunking, compressing, spilling to S3 — is unreachable, and any test of it passes while verifying nothing. This is the recurring shape: substrate returns success where real AWS signals failure.
Relation to #439
#439 corrected the reported default (256 KiB → 1 MiB) and deliberately stopped there: enforcement is a new error path with its own scope, and adding it alongside a default change would have conflated two observable behaviours in one release. v0.84.0 documents the absence in docs/services.md rather than leaving it implicit. This issue is the enforcement half.
Acceptance criteria
- Confirm the exact error code and message against the current SendMessage API reference — do not assume.
-
SendMessagewith a body exceeding the queue's effectiveMaximumMessageSizefails with that code, HTTP 400. - "Effective" means resolved through the default when the attribute is unset, so a bare queue enforces 1 MiB — reusing the same constant as SQS: MaximumMessageSize default is 256 KiB, AWS documents 1 MiB #439, not a second copy.
- A queue created with an explicit smaller
MaximumMessageSizeenforces that value. - Size is measured the way AWS measures it: confirm whether message attributes count toward the total, and cover it.
-
SendMessageBatch: confirm whether the limit applies per-message or to the batch total, and cover both. - A body exactly at the limit is accepted — the boundary is inclusive.
- Both the query and JSON protocols.
-
docs/services.mdreplaces the "does not enforce" note with the enforced behaviour.
Activity
feat(sqs): enforce MaximumMessageSize on SendMessage (#454) (#462)
scttfrdmn commentedon Aug 1, 2026
Shipped in #462 —
SendMessageandSendMessageBatchnow enforce the limit. Three things worth carrying back, one of which is the answer to this issue's first acceptance criterion and two of which the issue didn't anticipate.The error code is not in the API reference at all
The criterion was "confirm the exact error code and message against the current SendMessage API reference — do not assume." Taken literally, that's the finding: the reference declares no oversized-message error.
SendMessage's error list has no entry for it; itsInvalidMessageContentsis documented as a character-set error, not a length one; andBatchRequestTooLongis declared only onSendMessageBatch. So the code could not be derived from the model, and the issue's own hedge — "InvalidParameterValue(orInvalidMessageContents…)" — could not be settled by the route it proposed.What substrate emits, and where it comes from:
InvalidParameterValueOne or more parameters are invalid. Reason: Message must be shorter than N bytes.BatchRequestTooLongBatch requests cannot be longer than N bytes. You have sent M bytes.Both are transcribed from real-AWS responses captured in consumer bug reports — artilleryio/artillery#3463 for the per-message case, aws/aws-sdk-go-v2#3026 for the batch case. Independent reimplementations emit the same strings, which corroborates them as AWS's own wording rather than one project's invention. That's weaker evidence than a doc citation, so the code comment, CHANGELOG and
docs/services.mdall say so explicitly rather than implying a reference exists.Message attributes count toward the size
Listed here as an open question; the answer is yes. AWS: "all components of a message attribute are included in the 1 MiB message size restriction." Substrate measures name + data type + value, each as UTF-8 bytes, with a binary value counted at its raw length, not its base64 length — a 780-byte binary attribute is 780 bytes, not 1040. Message system attributes are excluded, per the same page.
This matters for your reproduction: a body sized just under the limit plus any attribute now fails where it previously succeeded. If you have a test asserting a near-limit body is accepted, check whether it also sets attributes.
A single oversized batch entry reports
BatchRequestTooLong, not the per-message errorThe issue treated the batch limit as one number. It's two — each entry against the queue's
MaximumMessageSize, and the combined payload against the request cap — and on a default queue they are the same number (AWS: the two limits "are both 1 MiB"). So one oversized entry breaches the total as well, and real AWS reportsBatchRequestTooLongfor it. Substrate checks the total first to match. If you're asserting on the per-message code from a batch call, you'll wantBatchRequestTooLongthere.Neither limit lowers the other: a queue with
MaximumMessageSize=1024still accepts a batch of ten 1 KiB entries, because the attribute is documented as a per-message cap and does not shrink the request payload cap.Other behaviour you can rely on
getAttrOrDefaultcallGetQueueAttributesuses, so the reported and enforced numbers cannot diverge — setMaximumMessageSize=1024and 1025 bytes is rejected. The error message names your queue's limit, not the default.MessageDeduplicationId, so the corrected retry with the same ID succeeds. The alternative would silently swallow the retry as a duplicate — a worse failure than the one being fixed, because it looks like success.MaximumMessageSize(non-numeric,0, negative, empty) falls back to the default rather than to zero, which would reject every message including an empty one.Not covered
Message attributes are parsed for measurement only — substrate still doesn't store or return them on
ReceiveMessage. Tracked as #461, so if you round-trip attributes rather than just sizing them, that's the one to watch.Releasing as part of v0.85.0.
fix(sqs): store and return message attributes (#461) (#465)
chore(release): v0.85.0 (#467)