Skip to content

Argument.FromAmong is validating more than the token for the arg #1556

Closed

Description

@iBicha

Consider config set key value where

  • config is Command
  • set is sub Command
  • key is Argument
  • and value is Argument

I used Argument.FromAmong to limit the possible keys I can configure, but the validation is being applied to both arguments.

If I set the allowed keys of to allowedkey1 and allowedkey2 using Argument.FromAmong and I call config set allowedkey1 somevalue
I get an error that somevalue is not a valid for argument value, and that I should choose either allowedkey1 or allowedkey2.

I checked that

internal ParseError? UnrecognizedArgumentError(Argument argument)

Is indeed validating two tokens (for the key and value arguments) while it should be only validating for the key argument

Activity

  1. iBicha commented on Jan 3, 2022

    @iBicha
    ContributorAuthor

    Adding more details, when setting

    KeyArgument.FromAmong("key1", "key2");
    ValueArgument.FromAmong("value1", "value2");
    

    and calling config set key1 value1, it errors out with

    Argument 'value1' not recognized. Must be one of:
            'key1'
            'key2'
    Argument 'key1' not recognized. Must be one of:
            'value1'
            'value2'
    

    Which means the both args are being validated against both allowlist. This leaves the cli in pretty much an unusable state.

  2. added a commit that references this issue on Jan 4, 2022
    0bad537
  3. added a commit that references this issue on Mar 6, 2024
    29c4d22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Parser and Binderbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions