Skip to content
New issue

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

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

Already on GitHub? # to your account

[CCRole] Failure case not properly caught #200

Open
Flame442 opened this issue Nov 20, 2021 · 0 comments
Open

[CCRole] Failure case not properly caught #200

Flame442 opened this issue Nov 20, 2021 · 0 comments
Assignees

Comments

@Flame442
Copy link
Contributor

Flame442 commented Nov 20, 2021

Describe the bug

The [p]ccrole add code is designed to exit the command early on role picking steps if a role could not be found but NONE is not explicitly passed. However, this catch can never happen, as there is an incorrect if statement.

Fox-V3/ccrole/ccrole.py

Lines 126 to 127 in 771d145

arole_list = await _get_roles_from_content(ctx, answer.content)
if arole_list is None:

The if checks if the result from _get_roles_from_content is None, however that function can never return None.

Fox-V3/ccrole/ccrole.py

Lines 16 to 37 in 771d145

async def _get_roles_from_content(ctx, content):
# greedy = Greedy[RoleConverter]
view = StringView(content)
rc = RoleConverter()
# "Borrowed" from discord.ext.commands.Command._transform_greedy_pos
result = []
while not view.eof:
# for use with a manual undo
previous = view.index
view.skip_ws()
try:
argument = view.get_quoted_word()
value = await rc.convert(ctx, argument)
except (CommandError, ArgumentParsingError):
view.index = previous
break
else:
result.append(value)
return [r.id for r in result]

There is only one return in this function, and it is the last line unindented, so there are no implicit None returns. It always returns a list, so the return value can never be None.

To Reproduce

  1. Load cog ccrole
  2. Run command [p]ccrole add
  3. On a step that requests a role, enter an invalid role name

Expected behavior

The response "Invalid answer, canceling"

Screenshots or Error Messages

image

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants