SnsSqsEnvelope - [ERROR] KeyError: 'SigningCertURL' #1228
Replies: 7 comments 5 replies
|
Seems like a bug in the parser model code. I would log it as a bug, as the discussions is not looked at too frequently by the project maintainers: For which the fix would be as follow: @root_validator(pre=True, allow_reuse=True)
def check_sqs_protocol(cls, values):
sqs_rewritten_keys = ("UnsubscribeURL", "SigningCertURL")
if any(key in sqs_rewritten_keys for key in values):
values["UnsubscribeUrl"] = values.pop("UnsubscribeURL", None)
values["SigningCertUrl"] = values.pop("SigningCertURL", None)
return valuesOtherwise you can use the |
|
hey @micaellasry , can you open an issue so this gets visibility? |
|
@ran-isenberg it was a hack for backwards compatibility to fix the names for |
|
@micaellasry how was this event created? An a fully setup SNS queue? I am not sure really if |
|
Hi @micaellasry, could you create a bug report and provide as much information as possible on the steps so we can try reproduce it? Parser Model is behaving as expected[1]. I suspect you might not want the SNS metadata information within your Lambda but simply the payload - if that's the case, please enable raw message delivery when subscribing your SQS queue to SNS; this will ensure your Lambda only receives the SQS envelope + payload instead of SNS+SQS. Suffice to say you'll then switch to SnsEnvelope too. That being said, please allow me to explain the history of why that branch logic is there. When SNS team integrated with Lambda, it corrected the When Parser SNS Model was created it took into account SQS protocol (SNS->SQS) and not Lambda protocol (SNS->Lambda). This meant that customers using SNS->SQS->Lambda had a [1] I've just re-generated SNS Lambda protocol and SNS SQS protocol events and Parser worked as expected. SNS->SQS subscription (SNS->SQS->Lambda) {
"Records": [
{
"messageId": "732a2fe0-ae74-459e-91c1-b9000a32af81",
"receiptHandle": "AQEB2Fhh2Sujp9h8CW3BUEXLRsuRHwWCqGV4jinH6xQ/x0qcCY0XQ8t4J7M/+qH5oDM/9mcsi7hpFOS+PRYwxU6yLIDt1agwy4vyRbus3qC/juCptnH+tqTaS3WTSEOXLLS3JPGAlga5hX6LYPatg+Vn0PVxy36lf0wyocnnh9iOSsOd4YUIQHNMXWcMfMobTITjUZItJX+6hqGw43ciZ7TmYBbflCNttOiYc6BLBQlCNh6S6HEHErJtBWr7MhgrVFVh15OE3l/WfFsd4NJwutl40NlHxra6V1JMYgtr/D0QVzIVGJc3YQNBv71MU8WIDEAAnvqet1w1wcG3IcvC8s3qtKxzOF43I6maLz8xtLaQ2hCTNMCYhTHasRNpyF34Ou1E81MZzkOQCS1K/am6xDovDQ==",
"body": "{\n \"Type\" : \"Notification\",\n \"MessageId\" : \"992beb60-b6fe-507e-8b53-b0798a6e534c\",\n \"TopicArn\" : \"arn:aws:sns:eu-west-1:123456789012:powertools265\",\n \"Message\" : \"'{\\\"hello\\\": \\\"world\\\"}'\",\n \"Timestamp\" : \"2022-06-07T11:45:20.450Z\",\n \"SignatureVersion\" : \"1\",\n \"Signature\" : \"bF03RCWw+vPDNTun1U2kn/Ng3z1k74FSx2Kp2v14HjEUVRFjp6oq+C568TcBUOx3eZLfxwgtW0JSNr+idV+MWIUtXfZxglthj9vOLAKwgZeB8Zu4e4Gi+pEN669LLn5ylO0oGL0SMaFVDfWmDXs5E7x8CEgt5lNmqc5GI88pC/RjIwwS3cpLk+3DGLpgLR/T7wt3s3A2Eq8hjhb7kny4J5WmFdDocbRi21VkmO2CYS+i518kHjYZgqPcUiLOZOJFsYdJU3FWu23AR5EaeCwWLir7mFovjkdLR6xPSui8lB9WFsNvBKkOuWZ6S1xenZJgCCaeX6El9G/61+sMdULTGQ==\",\n \"SigningCertURL\" : \"https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-7ff5318490ec183fbaddaa2a969abfda.pem\",\n \"UnsubscribeURL\" : \"https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:123456789012:powertools265:15189ad7-870e-40e5-a7dd-a48898cd9f86\"\n}",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1654602320475",
"SenderId": "AIDAISMY7JYY5F7RTT6AO",
"ApproximateFirstReceiveTimestamp": "1654602320482"
},
"messageAttributes": {},
"md5OfBody": "fd181a34ede44c6cb573dd6b10c844aa",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:eu-west-1:123456789012:powertools265",
"awsRegion": "eu-west-1"
}
]
}SNS->Lambda subscription {
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:eu-west-1:123456789012:powertools265:3f5bb551-d95e-4088-ac0d-f7dd674a76b6",
"Sns": {
"Type": "Notification",
"MessageId": "fdff66f1-8802-5c34-a142-3de8b330c72f",
"TopicArn": "arn:aws:sns:eu-west-1:123456789012:powertools265",
"Subject": null,
"Message": "'{\"hello\": \"world\"}'",
"Timestamp": "2022-06-07T11:39:30.302Z",
"SignatureVersion": "1",
"Signature": "fF2wK5FJdjFiijJoBaJrgEcVdhHsV1dij8WE+HvQG9TJ6ZrorDzM8503ELfghP2Widj3tG7IrUQSCgqh3EAx2Y2pexzISgEI7V0Q2koCZaknel9x6U/VA2eEOlEAsg/tpdysTRB+TUGyEqLyG9sX7qKS9EFqqCtP6l51PP371Lbw9xnA635drwZ2GwjiExxTiO4Ytwuuqnw58wu2pJFjFW87JFQjQW1WO1e9+ZXOXaqhBtjqQFExhfXZhkbDU3675BPnhjXh2xz3BTh/POL02Gnui1uaE79ZZMduNLehzrzRpFSIc3ZfYIVgMD0Ut/XJFW4MxRt3rJ7BZrIz47NgeA==",
"SigningCertUrl": "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-7ff5318490ec183fbaddaa2a969abfda.pem",
"UnsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:123456789012:powertools265:3f5bb551-d95e-4088-ac0d-f7dd674a76b6",
"MessageAttributes": {}
}
}
]
} |
|
"validators should either return the parsed value or raise a ValueError, TypeError, or AssertionError (assert statements may be used)." if it's the envelope code, i agree, validation error is the way to go |
|
@micaellasry sending a friendly reminder to recall our ask to create a bug report to investigate how PS: We can't reproduce it using SNS->Lambda, or SNS->SQS->Lambda. What we can reproduce is the Thank you! |
Uh oh!
There was an error while loading. Please reload this page.
I'm using v 1.26.0 and the SnsSqsEnvelope for a lambda function
The raw event I get is:
The Sns body contains UnsubscribeURL but does not contain SigningCertURL
I see in the source code: parser/models/sns.py:31 the following code
This causes the parsing to fail.
Why are these two values considered together?
All reactions