Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: SQS MessageAttribute Schema invalid #3398

Open
hrzbrg opened this issue Dec 4, 2024 · 3 comments
Open

Bug: SQS MessageAttribute Schema invalid #3398

hrzbrg opened this issue Dec 4, 2024 · 3 comments
Labels
bug Something isn't working discussing The issue needs to be discussed, elaborated, or refined need-response This item requires a response from a customer and will considered stale after 2 weeks parser This item relates to the Parser Utility

Comments

@hrzbrg
Copy link

hrzbrg commented Dec 4, 2024

Expected Behavior

Using the SQS Envelope and my custom body schema, I expected to be able to parse SQS events generated by Symfony Messenger.

Current Behavior

Parsing fails, because binaryValue is null. The SQS SqsMsgAttributeSchema defines it as optional string, but not nullish.

Code snippet

        "messageAttributes": {
          "X-Symfony-Messenger": {
            "stringValue": "{\"X-Message-Stamp-Symfony\\\\Component\\\\Messenger\\\\Stamp\\\\BusNameStamp\":\"[{\\\"busName\\\":\\\"external.event.bus\\\"}]\"}",
            "binaryValue": null,
            "stringListValues": [],
            "binaryListValues": [],
            "dataType": "String"
          },
          "type": {
            "stringValue": "App\\Event\\ChangeLogEvent",
            "binaryValue": null,
            "stringListValues": [],
            "binaryListValues": [],
            "dataType": "String"
          },
          "Content-Type": {
            "stringValue": "application/json",
            "binaryValue": null,
            "stringListValues": [],
            "binaryListValues": [],
            "dataType": "String"
          }
        },

Steps to Reproduce

  1. Use the Powertools Parser with envelope: SqsEnvelope to parse an SQS event with the above mentioned messageAttributes.

Possible Solution

BinaryValue could be set to be nullish: binaryValue: z.string().nullish()

Powertools for AWS Lambda (TypeScript) version

2.10

AWS Lambda function runtime

20.x

Packaging format used

npm

Execution logs

@hrzbrg hrzbrg added bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels Dec 4, 2024
Copy link

boring-cyborg bot commented Dec 4, 2024

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

@am29d am29d added good-first-issue Something that is suitable for those who want to start contributing help-wanted We would really appreciate some support from community for this one confirmed The scope is clear, ready for implementation parser This item relates to the Parser Utility and removed triage This item has not been triaged by a maintainer, please wait labels Dec 6, 2024
@am29d am29d moved this from Triage to Backlog in Powertools for AWS Lambda (TypeScript) Dec 6, 2024
@am29d
Copy link
Contributor

am29d commented Dec 6, 2024

Hey @hrzbrg thanks for dropping the issue, I will take a look why we missed it in the tests. Feel free to open a PR, if you want.

@dreamorosi
Copy link
Contributor

Hi, could you please share more info on the API call used to generate these SQS messages and how the event gets to the Lambda function?

I tried to send a message to SQS with attribute of type String, and the binary value field is undefined instead of null when I poll the queue:

{
    "Messages": [
        {
            "MessageId": "92f0ce33-f118-4a6a-8041-3f5016ab16e3",
            "ReceiptHandle": "AQEBsoWTnNZVxAUZOcJ....",
            "MD5OfBody": "5dea26020e811def89cbf972425f0e46",
            "Body": "two two",
            "MD5OfMessageAttributes": "2db1f7ff6cc285162639816522a868fb",
            "MessageAttributes": {
                "type": {
                    "StringValue": "application/json",
                    "DataType": "String"
                }
            }
        }
    ]
}

@dreamorosi dreamorosi added discussing The issue needs to be discussed, elaborated, or refined need-response This item requires a response from a customer and will considered stale after 2 weeks and removed good-first-issue Something that is suitable for those who want to start contributing help-wanted We would really appreciate some support from community for this one confirmed The scope is clear, ready for implementation labels Dec 12, 2024
@dreamorosi dreamorosi moved this from Backlog to On hold in Powertools for AWS Lambda (TypeScript) Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussing The issue needs to be discussed, elaborated, or refined need-response This item requires a response from a customer and will considered stale after 2 weeks parser This item relates to the Parser Utility
Projects
Development

No branches or pull requests

3 participants