Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix [p]diagnoseissues edge case for commands without a cog #6237

Conversation

Jackenmen
Copy link
Member

Description of the changes

ctx.cog can be None for commands without a cog which I do account for in the logic but apparently I forgot to also account for it when making the label. I simply rephrased it such that it doesn't include the cog name.

The issue can be reproduced by adding a global deny rule (through Permissions cog) for the help command for a user (make sure NOT to check on bot owner who can run commands regardless of permissions cog):

permissions addglobalrule deny help USER

With that setup, running diagnoseissues USER help without this PR should cause this uncatched exception:

╭─────────────────────────────── Traceback (most recent call last) ───────────────────────────────╮
│ /home/ubuntu/work/Red-DiscordBot/.venv/lib/python3.8/site-packages/discord/ext/commands/core.py │
│ :235 in wrapped                                                                                 │
│ ❱  235             ret = await coro(*args, **kwargs)                                            │
│ /home/ubuntu/work/Red-DiscordBot/redbot/core/core_commands.py:4782 in diagnoseissues            │
│ ❱ 4782         await ctx.send(await issue_diagnoser.diagnose())                                 │
│ /home/ubuntu/work/Red-DiscordBot/redbot/core/_diagnoser.py:959 in diagnose                      │
│ ❱ 959         result = await self._check_until_fail(                                            │
│ /home/ubuntu/work/Red-DiscordBot/redbot/core/_diagnoser.py:84 in _check_until_fail              │
│ ❱  84             check_result = await check()                                                  │
│ /home/ubuntu/work/Red-DiscordBot/redbot/core/_diagnoser.py:908 in _check_can_run_issues         │
│ ❱ 908         return await self._check_until_fail(                                              │
│ /home/ubuntu/work/Red-DiscordBot/redbot/core/_diagnoser.py:84 in _check_until_fail              │
│ ❱  84             check_result = await check()                                                  │
│ /home/ubuntu/work/Red-DiscordBot/redbot/core/_diagnoser.py:489 in _check_requires_cog           │
│ ❱ 489             cog=inline(self.ctx.cog.qualified_name)                                       │
╰─────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'qualified_name'

With this PR, however, the issue is properly reported and there are no uncatched exceptions.

Have the changes in this PR been tested?

Yes

@Jackenmen Jackenmen added the Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing. label Aug 14, 2023
@Jackenmen Jackenmen added this to the 3.5.5 milestone Aug 14, 2023
@github-actions github-actions bot added the Category: Core - Bot Commands This is related to core commands (Core and CogManagerUI cog classes). label Aug 14, 2023
@Jackenmen Jackenmen modified the milestones: 3.5.6, 3.5.5 Sep 14, 2023
@Jackenmen Jackenmen added the Changelog Entry: Added Changelog entry for this PR has already been added to changelog PR. label Sep 14, 2023
@Flame442 Flame442 self-assigned this Sep 14, 2023
@Flame442 Flame442 merged commit 1132498 into Cog-Creators:V3/develop Sep 14, 2023
18 checks passed
@Jackenmen Jackenmen deleted the fix_diagnoseissues_edge_case_for_cogless_commands branch September 14, 2023 02:05
Dav-Git pushed a commit to Dav-Git/Red-DiscordBot that referenced this pull request Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core - Bot Commands This is related to core commands (Core and CogManagerUI cog classes). Changelog Entry: Added Changelog entry for this PR has already been added to changelog PR. Type: Bug Unexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants