Repository navigation
fix(bot): skip the user count when Discord answers a server error - #411
Conversation
Discord answered the guild list of poststats with a 500 after the REST retries, and the task sent it to Sentry as an error (WOLFSTAR-3A). An outage is not a bug of the bot, and the next run posts the counts.
|
Architecture Data flow Review ✨ Nothing flagged · reviewed Tip Open a diagram on the canvas, then press W or click play to walk through the change one step at a time 🪧 More tips
Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it. |
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — the 5xx classification lives in the one helper every caller shares, so a Discord outage is skipped everywhere and real bugs still throw.
Reviewed changes
Reviewed the whole diff (single commit b45772f), plus the existing @discordjs/rest usage in the bot to confirm the instanceof pattern matches.
fetchApproximateUserCountnow takes aGuildPageReaderand returnsCountedorUnavailablewith the status. Only 5xxHTTPErrorandDiscordAPIErrorareUnavailable; other errors are rethrown.poststatslogs a warning and returnsnullonUnavailable, so the task no longer fails and Sentry no longer gets an issue for a Discord outage.ready.tslogs a[Startup]warning and skips the first analytics sync.guildCreateAnalyticsandguildDeleteAnalyticswrite the guild point alone when the count is unavailable.- Tests cover paging, a 500
HTTPError, a 502DiscordAPIErrorand a 403 that is rethrown.
claude-sonnet-5-5 | 𝕏
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #411 +/- ##
==========================================
+ Coverage 62.44% 62.53% +0.09%
==========================================
Files 269 269
Lines 9440 9447 +7
Branches 2242 2246 +4
==========================================
+ Hits 5895 5908 +13
+ Misses 3169 3161 -8
- Partials 376 378 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|

🔗 Linked issue
Sentry WOLFSTAR-3A.
❓ Type of change
📚 Description
On 18 November Discord answered
GET /users/@me/guildswith a 500, after the retries of the REST client.fetchApproximateUserCountthrew it, so thepoststatstask failed and Sentry got an error for an outage of Discord. The same throw would break the first analytics sync ofreadyand the guild points ofguildCreateAnalyticsandguildDeleteAnalytics.fetchApproximateUserCountnow takes the reader of the guilds as an argument and answersCountedorUnavailablewith the status. Only a 5xx (HTTPErrororDiscordAPIError) isUnavailable; any other error is still thrown, since it is a bug of the bot. OnUnavailable:poststatslogs a warning and skips the run. The next run is ten minutes later.readylogs a warning and skips the first sync.poststatswrites it later.guildCreateAnalyticsandguildDeleteAnalyticswrite the guild point alone.

Confidence Score: 5/5
The changes appear safe to merge.Reviews (1) · Last reviewed commit: "fix(bot): skip the user count when Disco..." · Reviewed by Greptile