'Why AWS SNS filtering doesn't ignore unknown message attributes?

The AWS documentation says that unknown message attributes are ignored by filter policy.

When Amazon SNS evaluates message attributes against the subscription filter policy, it ignores message attributes that aren't specified in the policy.

However, it seems to be incorrect. Let's say I have such policy:

{
    "customer_interests": ["rugby"]
}

but message with additional attribute, for example:

   "MessageAttributes": {
      "customer_interests": {
         "Type": "String.Array",
         "Value": "[\"rugby\"]"
      },
      "request_id": {
         "Type": "String",
         "Value":"123456"
      }
   }

is rejected, even though customer_interests value is correct. I tested it on different params and whenever I add a field that particular policy doesn't except, the message is rejected. Can someone explain to me this behaviour?



Solution 1:[1]

When Amazon SNS evaluates message attributes against the subscription filter policy, it ignores message attributes that aren't specified in the policy.

I think in the above statement the understanding of ignore is misleading; treat ignore as "rejected".

Check out this link which shows when the policy rejects messages

If any single attribute in this policy doesn't match an attribute assigned to the message, the policy rejects the message.

On the similar grounds, your filtering policy doesn't have request_id, which is why it is being rejected.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jatin Mehrotra