scrapinghub / spidermon

Scrapy Extension for monitoring spiders execution.
https://spidermon.readthedocs.io
BSD 3-Clause "New" or "Revised" License
528 stars 96 forks source link

[SlackMessageManager] Adding error handling for common permission issue #307

Closed further-reading closed 2 years ago

further-reading commented 3 years ago

fixes https://github.com/scrapinghub/spidermon/issues/306

The current implementation of slack messaging has the bot explicitly set its avatar when sending the message. This step is usually unnecessary - it is only required if the sender_name is different to the bot's name as if this argument is left blank it will use the same icon that was added when creating the bot. The method it uses to find the icon_url will fail if it's not set up in a specific way, which adds additional permission requirements and complexity when integrating slack messaging.

This change will allow the bot to still send a message if it can't find an icon_url.

further-reading commented 3 years ago

I'm not sure why those tests are failing - my code doesn't touch anything related to them.

Update: the tests are failing as the messaging in schematics was changed following the update to version 2.1.1: https://github.com/schematics/schematics/commit/3a144be0aa50f68a4da917e8d957b924dedf9a52 Will open a separate issue for this.

codecov[bot] commented 2 years ago

Codecov Report

Merging #307 (6ea7a1e) into master (1838ec9) will increase coverage by 0.22%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #307      +/-   ##
==========================================
+ Coverage   72.83%   73.06%   +0.22%     
==========================================
  Files          68       68              
  Lines        2901     2914      +13     
  Branches      324      326       +2     
==========================================
+ Hits         2113     2129      +16     
+ Misses        727      723       -4     
- Partials       61       62       +1     
Impacted Files Coverage Δ
spidermon/contrib/actions/slack/__init__.py 57.65% <100.00%> (+8.67%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1838ec9...6ea7a1e. Read the comment docs.

further-reading commented 2 years ago

Thanks @rennerocha - updated now + also added updates to the slack bot setup guide about setting OAuth permissions.