aws / aws/aws-cli

Bug on CLI input parsing

Open
#7,502 1 comment 0 reactions 0 assignees View on GitHub
bug p3 shorthand syntax
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

When the short hard syntax has open and closed curly braces in one of the values to the key, the CLI throws following error.

`awscli.argprocess.ParamError: Error parsing parameter '--patch-operations': Expected: ',', received: '}' for input:`

### Expected Behavior

CLI should process the string value as it is.

### Current Behavior

@https://github.com/aws/aws-cli/blob/9b6e981407138dc21c4546be10b3eba2a3a61740/awscli/shorthand.py#L136

at this line, regex computed only takes till the closed parenthesis.

e.g, for a key-value of

`value=arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:xxxxxxxxxx:function:Say-hello-world:${stageVariables.version}/invocations`

value extracted by the regex is 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:xxxxxxxxxx:function:Say-hello-world:${stageVariables.version'

### Reproduction Steps

Create API Gateway REST API with a resource path and method with lambda integration.

try the following command:
`newuri='arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:xxxxxxxxxx:function:Say-hello-world:${stageVariables.version}/invocations'`

`aws apigateway update-integration --rest-api-id xxxxxx --resource-id xxxxx --http-method ANY --patch-operation op="replace",path="/uri",value="$newuri" --debug`

**This command gives following output:**
```
Traceback (most recent call last):
File "/usr/local/Cellar/awscli/2.8.13/libexec/lib/python3.11/site-packages/awscli/argprocess.py", line 345, in _parse_as_shorthand
parsed = [self._parser.parse(v) for v in value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/awscli/2.8.13/libexec/lib/python3.11/site-packages/awscli/argprocess.py", line 345, in
parsed = [self._parser.parse(v) for v in value]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/awscli/2.8.13/libexec/lib/python3.11/site-packages/awscli/shorthand.py", line 172, in parse
return self._parameter()
^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/awscli/2.8.13/libexec/lib/python3.11/site-packages/awscli/shorthand.py", line 181, in _parameter
self._expect(',', consume_whitespace=True)
File "/usr/local/Cellar/awscli/2.8.13/libexec/lib/python3.11/site-packages/awscli/shorthand.py", line 355, in _expect
raise ShorthandParseSyntaxError(self._input_value, char,
awscli.shorthand.ShorthandParseSyntaxError: Expected: ',', received: '}' for input:
op=replace,path=/uri,value=arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:xxxxxxxx:function:Say-hello-world:${stageVariables.version}/invocations

```

### Possible Solution

This problem does not occur when the value is quoted.

### Additional Information/Context

_No response_

### CLI version used

aws-cli/2.8.13 Python/3.11.0 Darwin/21.6.0 source/x86_64 prompt/off

### Environment details (OS name and version, etc.)

MacOS

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.