Skip to content

click.option silently swallows invalid *args. #568

@peter5ac

Description

@peter5ac

As demonstrated below, the code for checking the choice type does not verify the entire string and will pass if a subset is given.

[click]$ setrackinfo ifcfg-param add 1
Usage: setrackinfo ifcfg-param add [OPTIONS] NODEID INTF PARAM [VALUE]

Error: Missing argument "Choice(['public', 'private'])".
[click]$ setrackinfo ifcfg-param add 1 pub
Usage: setrackinfo ifcfg-param add [OPTIONS] NODEID INTF PARAM [VALUE]

Error: Missing argument "Choice(['mtu', 'xmit_hash_policy'])".

I imagine the convert function should be updated to ensure that the given input is actually in the choices and not just a subset is matched.

class Choice(ParamType):
   ....
   ....
    def convert(self, value, param, ctx):
        # Exact match
        if value in self.choices:
            return value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions