Skip to content

fix(bot): skip the user count when Discord answers a server error - #411

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
fix/user-count-discord-outage
Nov 19, 2026
Merged

kodiakhq[bot] merged 1 commit into
mainfrom
fix/user-count-discord-outage

Conversation

@RedStar071

@RedStar071 RedStar071 commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

🔗 Linked issue

Sentry WOLFSTAR-3A.

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

On 18 November Discord answered GET /users/@me/guilds with a 500, after the retries of the REST client. fetchApproximateUserCount threw it, so the poststats task failed and Sentry got an error for an outage of Discord. The same throw would break the first analytics sync of ready and the guild points of guildCreateAnalytics and guildDeleteAnalytics.

fetchApproximateUserCount now takes the reader of the guilds as an argument and answers Counted or Unavailable with the status. Only a 5xx (HTTPError or DiscordAPIError) is Unavailable; any other error is still thrown, since it is a bug of the bot. On Unavailable:

  • poststats logs a warning and skips the run. The next run is ten minutes later.
  • ready logs a warning and skips the first sync. poststats writes it later.
  • guildCreateAnalytics and guildDeleteAnalytics write the guild point alone.

🤖 AI disclosure: Wolfstar Agent Kit modified this description. AI open source policy.


Read this PR faster    Follow each request

RetriggerView in GreptileConfidence 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

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.
@coldtea-pr-lens

coldtea-pr-lens Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Architecture

Walkthrough of Gracefully handle Discord 5xx outages when fetching user counts, in four steps

Read this PR faster


Data flow

Data flow diagram for wolfstar-project/wolfstar at b45772f

Follow each request


Review

✨ Nothing flagged · reviewed b45772f


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
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through
  • The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change
  • The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture… row. Drawing still runs as before
  • Set github.draw: on-demand in .github/pr-lens.yml and PR Lens stops drawing pull requests on its own. Comment @pr-lens draw on a pull request when you want that one drawn
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works
  • After a push, tick Redraw to draw the latest commit
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion
  • Set github.description: false in .github/pr-lens.yml to stop PR Lens adding buttons to your PR descriptions

Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it.  Star PR Lens on GitHub

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

  • fetchApproximateUserCount now takes a GuildPageReader and returns Counted or Unavailable with the status. Only 5xx HTTPError and DiscordAPIError are Unavailable; other errors are rethrown.
  • poststats logs a warning and returns null on Unavailable, so the task no longer fails and Sentry no longer gets an issue for a Discord outage.
  • ready.ts logs a [Startup] warning and skips the first analytics sync.
  • guildCreateAnalytics and guildDeleteAnalytics write the guild point alone when the count is unavailable.
  • Tests cover paging, a 500 HTTPError, a 502 DiscordAPIError and a 403 that is rethrown.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@github-project-automation github-project-automation Bot moved this from Todo to Review Approved in Wolfstar Nov 19, 2026
@kodiakhq
kodiakhq Bot merged commit ea45f76 into main Nov 19, 2026
23 of 25 checks passed
@kodiakhq
kodiakhq Bot deleted the fix/user-count-discord-outage branch November 19, 2026 13:37
@github-project-automation github-project-automation Bot moved this from Review Approved to Done in Wolfstar Nov 19, 2026
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.53%. Comparing base (969abb1) to head (b45772f).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
projects/bot/src/lib/utilities/analytics.ts 83.33% 0 Missing and 2 partials ⚠️
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     
Flag Coverage Δ
unit 62.53% <83.33%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant