The icon_url argument is an optional argument when sending a slack message to change the avatar displayed when the message is sent. In order to find the content to place in this argument the code takes two steps
Gets a dict that contains details of all users in a slack organisation.
Searches for the SPIDERMON_SLACK_SENDER_NAME in in this dict.
However, these steps are prone to fail. First, to achieve step 1 the users:read permission needs to be added to the bot, but a bot that is intended to just write messages to slack should function with only the chat:write permission. Second, it is possible for some integrations to not appear in the specific list that spidermon is looking for users in, resulting in a key error when trying to grab its own details.
As I mentioned this is an optional argument - if this is not included in the slack chat_postMessage call then it just uses the icon that was set by the bot's developer. The only use case is when the bot is using an icon from another user/app within the organisation, which feels like it's probably an edge case. As such I propose adding error handling when attempting to find the icon_url so basic slack bots will work as expected.
The current implementation of slack messaging causes errors when certain permissions are missing. The issue come from the following line
The icon_url argument is an optional argument when sending a slack message to change the avatar displayed when the message is sent. In order to find the content to place in this argument the code takes two steps
SPIDERMON_SLACK_SENDER_NAME
in in this dict.However, these steps are prone to fail. First, to achieve step 1 the
users:read
permission needs to be added to the bot, but a bot that is intended to just write messages to slack should function with only thechat:write
permission. Second, it is possible for some integrations to not appear in the specific list that spidermon is looking for users in, resulting in a key error when trying to grab its own details.As I mentioned this is an optional argument - if this is not included in the slack
chat_postMessage
call then it just uses the icon that was set by the bot's developer. The only use case is when the bot is using an icon from another user/app within the organisation, which feels like it's probably an edge case. As such I propose adding error handling when attempting to find the icon_url so basic slack bots will work as expected.