You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: SQSMessageAttribute.binary_value raises KeyError for String attributes #8712
SQSMessageAttribute.string_value and binary_value are typed str | None, so reading the value an attribute doesn't carry should return None.
Current Behaviour
Both properties index the dict directly (self["stringValue"], self["binaryValue"]). Lambda only sends the field that matches the attribute's type; the SQS example event in the Lambda docs has {"stringValue": "myValue", "stringListValues": [], "binaryListValues": [], "dataType": "String"} with no binaryValue. So binary_value on any String or Number attribute, and string_value on any Binary attribute, raise KeyError.
The test event tests/events/sqsEvent.json puts both stringValue and binaryValue on one attribute, which is why the existing tests don't hit this. The Pydantic SqsMsgAttributeModel already declares both fields optional.
Thanks @anishmehta24, confirmed. Lambda only sends the field matching the attribute type, our fixture has both on the same attribute, so the tests never caught it. I'll review #8713. Goes into 3.40.0.
Activity
leandrodamascena commentedon Oct 30, 2026
Thanks @anishmehta24, confirmed. Lambda only sends the field matching the attribute type, our fixture has both on the same attribute, so the tests never caught it. I'll review #8713. Goes into 3.40.0.