Skip to content

SQS: the 10-attribute maximum and the attribute-name character rules are unenforced #472

Closed

Description

@scttfrdmn

Follow-up from #461, which made message attributes round-trip. Both rules below are reachable now that attributes are stored.

The gaps

The SQS developer guide's Message metadata → Message attributes page states three constraints substrate does not enforce:

  1. At most 10 attributes per message. SQS: message attributes are measured but not stored or returned #461 has a test asserting a 10-attribute message is accepted (the boundary), but an 11th is accepted too. Real SQS rejects it.
  2. Reserved name prefixes. A name may not start with AWS. or Amazon. — those are reserved for AWS use.
  3. Name character and shape rules. Names may contain alphanumerics, hyphen, underscore and period only; may not start or end with a period; may not contain two consecutive periods; and are limited to 256 characters. Names are case-sensitive and must be unique within a message.

There is also a fourth, related to DataType rather than the name: the type must be one of String, Number, Binary or one of those with a custom suffix. Number in particular is documented as having to be a valid numeric value.

Provenance to establish first

The SendMessage reference's Errors section documents InvalidMessageContents and UnsupportedOperation but does not name the error for any of these. #454 and #461 hit the same wall — the codes and messages have to come from captured real-AWS responses or from independent reimplementations emitting identical strings, and whichever it is must be stated plainly rather than implied to be a doc citation. Do not guess a code.

Acceptance criteria

  • An 11-attribute message is rejected with the real code, message and HTTP status; provenance stated
  • A name starting with AWS. or Amazon. is rejected; the check is case-sensitive or case-insensitive per observed behaviour, not per assumption
  • A name with a leading period, trailing period, two consecutive periods, an illegal character, or over 256 characters is rejected
  • A Number attribute whose value is not numeric is rejected
  • The rules apply to SendMessage and each SendMessageBatch entry, with the batch's per-entry error shape (BatchResultErrorEntry) rather than a whole-request failure where AWS uses one
  • The 10-attribute boundary test from SQS: message attributes are measured but not stored or returned #461 still passes
  • docs/services.md — the two "not enforced" limits under §Message attributes are replaced

Activity

  1. added this to the v0.86.0 milestone on Aug 2, 2026
  2. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in v0.86.0 (#485). Two findings worth recording, one of which is a trap.

    The AWS./Amazon. prefix check is case-INsensitive — the opposite of #452's aws: tag
    rule.
    The SQS developer guide says an attribute name "can't start with AWS. or
    Amazon. (or any casing variations)", and LocalStack matches its regex against
    name.lower(). EC2 tags are the other way: AWS:foo is an ordinary user tag and #452
    established that deliberately. Both are correct, because the two services document
    different rules — so the two checks are not shared, and both code comments say why. A
    reader who knows one and assumes the other will get it backwards, which is exactly what the
    aws.foo and AwS.foo test rows exist to catch.

    The 10-attribute rejection has no captured code or message anywhere. "Each message can
    have up to 10 attributes" is documented, but the rejection is not: SendMessage's Errors
    section names neither, the API model carries nothing, and neither moto nor LocalStack
    enforces the count at all
    — which is likely why substrate accepting an eleventh attribute
    went unnoticed until #461 made attributes observable. So substrate emits
    InvalidParameterValue (inferred from the sibling attribute rules, which LocalStack reports
    under that code) with its own message text interpolating the count and the limit. That
    provenance is labelled as inferred in the code, the CHANGELOG and docs/services.md.
    It is the weakest claim in the change and is marked as such.

    Everything else has a source. The name and type messages are LocalStack's verbatim,
    snapshot-tested against real AWS — including the trailing space and the odd "upper and lower
    score characters" phrasing, reproduced exactly, with a comment warning against "fixing"
    them. Two guide rules needed separate handling: sequential periods pass the character class
    (.. matches ^[a-zA-Z0-9_.-]*$), so there is an explicit check; and uniqueness within a
    message is structural, since attributes arrive as a Go map.

    Number value validation is implemented, since a Number attribute holding "abc" is
    exactly the silent-success shape this tracker exists to close. The guide bounds it precisely
    (38 digits of precision, 10^-128 to 10^+126) while LocalStack validates only the character
    set, so the range check is substrate's own and the bounds are computed exactly rather than
    via float64 — 1e126 as a float64 is not 10^126, and there is a mutation test for that.

    SendMessageBatch reports per-entry failures at HTTP 200 with SenderFault: true,
    which required adding the BatchResultErrorEntry type substrate never had (both batch paths
    emitted empty Failed placeholders). That is deliberately different from the batch size
    check ten lines away, which fails the whole request: BatchRequestTooLong is a documented
    whole-request error about the aggregate, while an attribute violation belongs to one entry.

    A message written into state before these rules existed is still returned as stored, because
    withholding it would make a recorded run unreplayable. Tracked in #491.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: sqsfidelitytype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions