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

Client-side parameter validation does not check 'max' value; displays erroneous error message that the max allowed value is infinity #2165

Open
emdelaney opened this issue Sep 23, 2020 · 3 comments
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue

Comments

@emdelaney
Copy link

Describe the bug
The parameter validation logic does not validate the 'max' value specified in the AWS service model; it only checks the 'min' value. As a result, it displays incorrect error messages, suggesting that the max allowed value is always inf.

Steps to reproduce
Using any recent version of the awscli:

aws globalaccelerator create-listener --accelerator-arn irrelevant --protocol UDP --port-ranges FromPort=0,ToPort=65535

Parameter validation failed:
Invalid range for parameter PortRanges[0].FromPort, value: 0, valid range: 1-inf

The global accelerator service model has a max value for this parameter of 65535 (and the API will reject requests beyond 65535), but the error message suggests 1-inf is the valid range.

Expected behavior
The error message should display the model's maximum value, if it exists.

Additionally, should the validator validate 'max' constraints, in addition to 'min' ones?

Debug logs

Traceback (most recent call last):
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 217, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 358, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 527, in __call__
    return self._operation_caller.invoke(
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 649, in invoke
    response = self._make_client_call(
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/awscli/clidriver.py", line 661, in _make_client_call
    response = getattr(client, xform_name(operation_name))(
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/botocore/client.py", line 276, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/botocore/client.py", line 558, in _make_api_call
    request_dict = self._convert_to_request_dict(
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/botocore/client.py", line 606, in _convert_to_request_dict
    request_dict = self._serializer.serialize_to_request(
  File "/usr/local/Cellar/awscli/1.17.0/libexec/lib/python3.8/site-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid range for parameter PortRanges[0].FromPort, value: 0, valid range: 1-inf
2020-09-23 14:16:36,740 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

Parameter validation failed:
Invalid range for parameter PortRanges[0].FromPort, value: 0, valid range: 1-inf

I can put up a pull request for this; it seems like the bug (not reading or checking the max value) is pretty obvious here. Let me know if you think we should validate the max parameter, or just print it correctly when validating the min value.

@emdelaney emdelaney added the needs-triage This issue or PR still needs to be triaged. label Sep 23, 2020
@swetashre
Copy link
Contributor

swetashre commented Oct 6, 2020

@emdelaney - Thank you for your post. We avoid doing a lot of client side validation to help ensure clients are forward compatible. For example EC2 increased the length of the IDs and if we validated the length of instance ids then when the API started to return longer IDs the client would fail to round trip the id due to validation.

But in this case i agree printing the correct value range would be more useful. Marking this as feature request for displaying correct value range in the error message.

@swetashre swetashre self-assigned this Oct 6, 2020
@swetashre swetashre added feature-request This issue requests a feature. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 6, 2020
@emdelaney
Copy link
Author

Thanks! I have a PR open that does just that ( #2166 ). Please let me know if you have any feedback on it. Thanks!

@swetashre swetashre added bug This issue is a confirmed bug. feature-request This issue requests a feature. and removed feature-request This issue requests a feature. bug This issue is a confirmed bug. labels Jan 22, 2021
@swetashre swetashre assigned kdaily and unassigned swetashre Mar 25, 2021
@github-actions
Copy link

Greetings! It looks like this issue hasn’t been active in longer than one year. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

4 participants