"[p]muteset makerole" can error out and fail if ratelimited #4530

Closed
opened 2020-10-26 07:22:53 +01:00 by newgreenshoot · 5 comments
newgreenshoot commented 2020-10-26 07:22:53 +01:00 (Migrated from github.com)

Command bugs

Command name

[p]muteset makerole

What cog is this command from?

Mutes

What were you expecting to happen?

The command to successfully create a new role with overrides configured for a server's channels and categories

What actually happened?

It causes an exception, leaving a partially-configured role and posting an error in chat. The traceback ends with discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 429 Too Many Requests (error code: 0): You are being rate limited.

How can we reproduce this issue?

  1. Start with a server that has no mute role configured, and a considerably large number of channels.
  2. Run [p]muteset makerole [role]
  3. If Discord ratelimits Red while it's applying overrides, the command will error out leaving the role only partially configured.
# Command bugs #### Command name `[p]muteset makerole` #### What cog is this command from? Mutes #### What were you expecting to happen? The command to successfully create a new role with overrides configured for a server's channels and categories #### What actually happened? It causes an exception, leaving a partially-configured role and posting an error in chat. The traceback ends with `discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 429 Too Many Requests (error code: 0): You are being rate limited.` #### How can we reproduce this issue? 1. Start with a server that has no mute role configured, and a considerably large number of channels. 2. Run `[p]muteset makerole [role]` 3. If Discord ratelimits Red while it's applying overrides, the command will error out leaving the role only partially configured.
Drapersniper commented 2020-10-26 09:47:13 +01:00 (Migrated from github.com)

Please provide the full traceback as it can help debugging the issue. Seeing just the last line isn't very helpful .

Please provide the full traceback as it can help debugging the issue. Seeing just the last line isn't very helpful .
newgreenshoot commented 2020-10-26 10:12:28 +01:00 (Migrated from github.com)

My bad, does this work?:

redbot[50180]: [2020-10-26 04:09:45] [ERROR] red: Exception in command 'muteset makerole'
redbot[50180]: Traceback (most recent call last):
redbot[50180]:   File "/home/redbeta/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
redbot[50180]:     ret = await coro(*args, **kwargs)
redbot[50180]:   File "/home/redbeta/.local/lib/python3.8/site-packages/redbot/cogs/mutes/mutes.py", line 697, in make_mute_role
redbot[50180]:     errors = await asyncio.gather(*tasks)
redbot[50180]:   File "/home/redbeta/.local/lib/python3.8/site-packages/redbot/cogs/mutes/mutes.py", line 729, in _set_mute_role_overwrites
redbot[50180]:     await channel.set_permissions(role, overwrite=overs, reason=_("Mute role setup"))
redbot[50180]:   File "/home/redbeta/.local/lib/python3.8/site-packages/discord/abc.py", line 658, in set_permissions
redbot[50180]:     await http.edit_channel_permissions(self.id, target.id, allow.value, deny.value, perm_type, reason=reason)
redbot[50180]:   File "/home/redbeta/.local/lib/python3.8/site-packages/discord/http.py", line 258, in request
redbot[50180]:     raise HTTPException(r, data)
redbot[50180]: discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being rate limited.
My bad, does this work?: ``` redbot[50180]: [2020-10-26 04:09:45] [ERROR] red: Exception in command 'muteset makerole' redbot[50180]: Traceback (most recent call last): redbot[50180]: File "/home/redbeta/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped redbot[50180]: ret = await coro(*args, **kwargs) redbot[50180]: File "/home/redbeta/.local/lib/python3.8/site-packages/redbot/cogs/mutes/mutes.py", line 697, in make_mute_role redbot[50180]: errors = await asyncio.gather(*tasks) redbot[50180]: File "/home/redbeta/.local/lib/python3.8/site-packages/redbot/cogs/mutes/mutes.py", line 729, in _set_mute_role_overwrites redbot[50180]: await channel.set_permissions(role, overwrite=overs, reason=_("Mute role setup")) redbot[50180]: File "/home/redbeta/.local/lib/python3.8/site-packages/discord/abc.py", line 658, in set_permissions redbot[50180]: await http.edit_channel_permissions(self.id, target.id, allow.value, deny.value, perm_type, reason=reason) redbot[50180]: File "/home/redbeta/.local/lib/python3.8/site-packages/discord/http.py", line 258, in request redbot[50180]: raise HTTPException(r, data) redbot[50180]: discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being rate limited. ```
Drapersniper commented 2020-10-26 10:35:17 +01:00 (Migrated from github.com)

for channel in ctx.guild.channels:
    tasks.append(self._set_mute_role_overwrites(role, channel))
errors = await asyncio.gather(*tasks)

Seems to be the source of the problem, I would assume the command is being run on a server with many channels (@chloecormier can you confirm how many channels are in the server?)

```py for channel in ctx.guild.channels: tasks.append(self._set_mute_role_overwrites(role, channel)) errors = await asyncio.gather(*tasks) ``` Seems to be the source of the problem, I would assume the command is being run on a server with many channels (@chloecormier can you confirm how many channels are in the server?)
newgreenshoot commented 2020-10-26 10:37:40 +01:00 (Migrated from github.com)

Right, the server I can reproduce this in has 209 text channels and 19 voice channels... yeah, I know it's excessive.

Right, the server I can reproduce this in has 209 text channels and 19 voice channels... yeah, I know it's excessive.
Jackenmen commented 2020-10-26 11:56:11 +01:00 (Migrated from github.com)

Whatever we decide to do, we should remember to do it for all the usage of gather we have in Mutes.

Whatever we decide to do, we should remember to do it for all the usage of `gather` we have in Mutes.
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#4530
No description provided.