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

Handling SNS message fails if SNS message contains only numeric values #1466

Open
qsweber opened this issue Apr 1, 2018 · 1 comment
Open

Comments

@qsweber
Copy link

qsweber commented Apr 1, 2018

message = json.loads(record['Sns']['Message'])

I sent a message to SNS which consisted simply of the number 1:

sns = boto3.resource('sns')
topic = sns.Topic('arn:aws:sns:us-west-2:foo:bar')
topic.publish(Message='1')

This caused the following failure when the downstream lambda function was invoked:

[1522557727786] 'int' object has no attribute 'get': AttributeError
Traceback (most recent call last):
  File "/var/task/handler.py", line 509, in lambda_handler
  return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 240, in lambda_handler
  return handler.handler(event, context)
  File "/var/task/handler.py", line 384, in handler
  whole_function = self.get_function_for_aws_event(records[0])
  File "/var/task/handler.py", line 293, in get_function_for_aws_event
  if message.get('command'):
AttributeError: 'int' object has no attribute 'get'
@qsweber qsweber changed the title Fails if message is numeric Fails if SNS message contains only numeric values Apr 1, 2018
@qsweber qsweber changed the title Fails if SNS message contains only numeric values Handling SNS message fails if SNS message contains only numeric values Apr 1, 2018
@qsweber
Copy link
Author

qsweber commented Apr 1, 2018

Addressing this is not urgent, since it's very easy to avoid this by making my SNS messages contain non-integers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant