-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
string indices must be integers: TypeError #24
Comments
Met similar error for CloudWatch Alarm
|
Same issue! Reverting to previous version seems to have fixed it:
This seems to be the problem: #23 It's not parsing the message from a json to a python dictionary anymore, but it is accessing the object as if it were a dictionary here: https://github.com/terraform-aws-modules/terraform-aws-notify-slack/blob/master/functions/notify_slack.py#L22 Not sure why the change was made though. There's nothing on the PR nor release notes. |
@antonbabenko @ryron01 maybe you can shed some light on this? I was going to fork this and open a PR reverting #23, but that's the only commit in the latest release. If this is really the issue then deleting release 1.11 instead might be the best option. |
If I understand correctly and I ran it myself to test the fix introduced in #23, it was necessary. Additionally, we need to fix the error Anyone? |
I think the error is what I pointed out in my previous comment:
So at line 22, messsage is of type "string", not "dict". Thus accessing it as
Just out of curiosity, what was that fixing? I reverted to 1.10.0 on my environments and its working fine, so I guess the fix might have been targeted at a different use case than mine. |
Hi, this is just sharing. But not all lambda execution failed but in some condition if my understanding is correct. |
@nyamada2 is correct that is the error that #23 was fixing. In the incoming event, event['Records'][0]['Sns']['Message'] is not valid json in my case. See the example below. If someone can provide an example AWS event that includes
|
Full event from CloudWatch:
So in my case |
Hi @ryron01 I'm not sure I got it right, but your example is a generic example message. This module documentation says it supports CloudWatch Events only, and it seems that every CW event payload is a json (if someone has an example where it isn't that'd be helpful). And if it's not a json, then the rest of the module will fail anyway, wouldn't it? Anyway, wouldn't the best solution to simply try to load the message as a json, catch any JSONDecodeError and discard it if it fails? EDIT: Oh, I see you already developed a solution along these lines here #25 👍 |
I would love to post the complete message here, as being sent by SNS towards lambda... but.. how do I get the message from the log? |
This issue is also affecting us too, both for 1.10.0 and 1.11.0 |
@ryron01 's patch works for me. |
v1.13.0 has been released with similar fix. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Just rolled out the latest pull, which still contains an error:
I am worthless when it comes to python, so I don't have a clue as to how to solve this one. When publishing plain text to this topic, it does work.
The text was updated successfully, but these errors were encountered: