Skip to content

SQS message-attribute rules are not applied to attributes already in state #491

Closed

Description

@scttfrdmn

What

v0.86.0 added SQS's message-attribute count, name, type and Number value rules.
They are enforced on send only. A message written into state before those rules
existed — from an event log recorded against an older substrate — can still carry an
illegal attribute name, an eleventh attribute, or a Number attribute holding "abc",
and ReceiveMessage returns it as stored.

Why it was left that way

Deliberately, and the reasoning should survive any fix: withholding a stored message
would make a recorded run unreplayable.
Substrate's core property is that replaying an
event log reproduces the same observations; a validation added later that silently drops
messages an older run enqueued would break exactly that. The message was accepted by the
substrate that recorded it, so replay must keep returning it.

So this is not a "validate on receive" bug report. It is a question of whether
anything should be done at all, and if so what.

Options, roughly in order of how much they preserve replay

  1. Nothing, documented — the current state. docs/services.md says the rules apply
    on send, not on receive, and why. Reachable only through a pre-existing event log, so
    no new run can produce it.
  2. Warn, don't withhold — log at receive when a stored attribute violates a rule, so
    the operator learns their fixture predates the rules without the observation changing.
    Keeps replay exact.
  3. A replay-time report — surface it through the existing replay/inspection
    machinery rather than the data plane, since that is where "this log contains something
    a current substrate would refuse" actually belongs.

Option 2 or 3 seems right; option 1 is defensible. What would be wrong is rejecting or
dropping the message at receive.

Acceptance criteria

  • A decision, recorded on this issue with its reasoning.
  • If anything ships: a test that a stored-illegal message is still returned with
    the same body and attributes, alongside whatever the new signal is.
  • docs/services.md's "The rules apply on send, not on receive" paragraph updated to
    match.

Referenced as tracked separately from docs/services.md and the v0.86.0 CHANGELOG.

Activity

  1. added
    type: chore
    on Aug 2, 2026
  2. added this to the v0.87.0 milestone on Aug 2, 2026
  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in dcf8ffa (#513), in v0.87.0. Your criterion was that the decision be recorded on the issue, so the reasoning is here rather than only in the CHANGELOG.

    Decision: option 2 — warn, don't withhold. ReceiveMessage now logs at WARN when a stored message's attributes violate a rule sqsCheckMessageAttributes enforces on send, naming the queue, the message ID and the rule violated. The message is still returned, in full, exactly as stored.

    Returning it is the decision, not an omission, and your reasoning is why. A message written by an older substrate was accepted by the substrate that recorded it, so withholding or dropping it now would make a recorded run unreplayable — the one outcome you ruled out, and it would break the property the whole emulator rests on. There is a second reason your report does not mention: a receive-time rejection has no AWS behaviour to imitate. Real SQS never accepted the message, so there is no real response to copy, and substrate would be inventing an observation. Rejecting on receive is deliberately not done, and the suite fails if anyone adds it — the replay gate is TestSQS_MessageAttributes_StoredAttributesAreReturnedNotWithheld, and the mutation harness for this change includes "withhold via continue", "reject the whole request", "strip the offending attributes" and "blank the body as a safe redaction" specifically so a future well-meaning fix trips all four.

    Option 1 (nothing) was rejected because it leaves an operator with a fixture that quietly predates the rules and no way to know.

    Option 3 is the better home and is filed, not dropped — #512. The violation is a property of the log rather than of any one request, so reporting it per-receive is the wrong shape in three ways: it fires only for data that is actually read, it repeats, and it is easy to miss in a test's log output. It needs a surface in the replay machinery that does not exist today, which is the only reason it is not this release. If the warning proves too easy to miss, #512 is where it goes.

    Two scope choices, both argued and both mutation-tested:

    • The whole stored attribute set is checked, not the subset the request asked for. The violation is a property of what is in state, and SQS: message attributes are measured but not stored or returned #461's selection rule means a request naming no attribute names gets no attributes back — so a subset check would hide the violation from exactly the caller most likely to be replaying an old log. There is a test for "the request naming no attributes still warns," and it exists to catch that regression.
    • It fires on every receive, not once per message. A message redelivered after its visibility timeout is a fixture being exercised again, and remembering which messages have already warned would be per-process state a replay could not reproduce.

    Send-time rejection is unchanged, so no new run can produce this state — that is asserted too, including that the queue depth stays at zero. The tests write the illegal attribute set directly into state, which is the point rather than a shortcut: no send path stores one any more, so the only way this state exists is an event log recorded against a substrate that predates the rules.

    docs/services.md §"Message attributes" now carries the decision and the replay reasoning, so a consumer who finds the warning in their logs can read why the message came back anyway.

    Thank you for filing this as a decision request rather than as a bug report — the distinction is what made the right answer reachable.

  4. added a commit that references this issue on Aug 2, 2026
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: sqstype: chore

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions