tools/c7n_mailer - on slack error show err text and status code #3652
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trying to address and issue reported on gitter, basically the error log tries to decode json from the slack api response, and barfs if its not json, which obscures the original message.
from chat
Looking for some help, how would it be possible that the json response c7n_mailer is trying to send to my slack incoming webhook could not be decoded?
[WARNING] 2019-03-08T17:24:34.882Z f125ba06-c7ad-4751-9dde-8c98a5207dfd Error: Incorrect padding Unable to base64 decode slack_token, will assume plaintext. Traceback (most recent call last): File "/var/task/c7n_mailer/sqs_queue_processor.py", line 182, in process_sqs_message slack_delivery.slack_handler(sqs_message, slack_messages) File "/var/task/c7n_mailer/slack_delivery.py", line 116, in slack_handler self.send_slack_msg(key, payload) File "/var/task/c7n_mailer/slack_delivery.py", line 187, in send_slack_msg self.logger.info("Error in sending Slack message: %s" % response.json()) File "/var/task/requests/models.py", line 897, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib64/python2.7/json/init.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded END RequestId: f125ba06-c7ad-4751-9dde-8c98a5207dfd