You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a shorthand parameter value fails to parse, the AWS CLI is supposed to
print the offending input with a caret (^) pointing at the exact character
where parsing failed. Instead, the error message prints the literal text {self._error_location()}.
The cause is in awscli/shorthand.py, ShorthandParseSyntaxError._construct_msg: the method concatenates an
f-string with a plain string literal, and the final fragment is missing the f prefix, so the placeholder is never interpolated:
The sibling exception DuplicateKeyInObjectError._construct_msg was
converted to f-strings correctly in the same commit, which is why only ShorthandParseSyntaxError is affected.
Regression Issue
Select this option if this issue appears to be a regression.
Expected Behavior
$ aws dynamodb put-item --table-name t --item 'a=b,c==d'
Error parsing parameter '--item': Expected: ',', received: '=' for input:
a=b,c==d
^
This is the output produced by AWS CLI v1 releases before August 2024.
Current Behavior
$ aws dynamodb put-item --table-name t --item 'a=b,c==d'
Error parsing parameter '--item': Expected: ',', received: '=' for input:
{self._error_location()}
The same broken output is produced for every command whose shorthand value
raises ShorthandParseSyntaxError (--tags, --item, --attributes, --environment, etc.). For long shorthand expressions the caret is the main
diagnostic for locating the mistake, so its loss makes these errors much
harder to act on.
Reproduction Steps
Any invalid shorthand value reproduces it; no credentials or API calls are
needed since parsing happens client-side:
aws dynamodb put-item --table-name t --item 'a=b,c==d'
Or directly against the parser:
fromawscli.shorthandimportShorthandParserShorthandParser().parse('a=b,c==d')
# ShorthandParseSyntaxError: Expected: ',', received: '=' for input:# {self._error_location()}
Possible Solution
Move the placeholder into the f-string fragment in ShorthandParseSyntaxError._construct_msg:
This restores the pre-regression message byte-for-byte. The existing unit
tests only assert the exception type (test_error_parsing in tests/unit/test_shorthand.py), which is why this went unnoticed; a fix
should also add tests asserting the full message content, including the
caret position.
Additional Information/Context
DuplicateKeyInObjectError messages (duplicate shorthand keys) still
render correctly and are unaffected.
AWS CLI v2 maintains its own copy of shorthand.py on the v2 branch and
is not affected.
Searched existing issues/PRs for _error_location, ShorthandParseSyntaxError, and related terms; no existing report found.
Issue Bug on CLI input parsing #7502 mentions a shorthand error message but concerns a different
parsing bug (filed 2022, before this regression).
This report was generated with the assistance of AI tooling and reviewed by
Abuhaithem, per the repository's Automated Tools contribution guidelines.
CLI version used
aws-cli/1.45.40 (current develop); regression present since 1.34.x
Environment details (OS name and version, etc.)
All platforms (message construction is platform-independent); verified on Linux (kernel 6.17), Python 3.12
Describe the bug
When a shorthand parameter value fails to parse, the AWS CLI is supposed to
print the offending input with a caret (
^) pointing at the exact characterwhere parsing failed. Instead, the error message prints the literal text
{self._error_location()}.The cause is in
awscli/shorthand.py,ShorthandParseSyntaxError._construct_msg: the method concatenates anf-string with a plain string literal, and the final fragment is missing the
fprefix, so the placeholder is never interpolated:The sibling exception
DuplicateKeyInObjectError._construct_msgwasconverted to f-strings correctly in the same commit, which is why only
ShorthandParseSyntaxErroris affected.Regression Issue
Expected Behavior
This is the output produced by AWS CLI v1 releases before August 2024.
Current Behavior
The same broken output is produced for every command whose shorthand value
raises
ShorthandParseSyntaxError(--tags,--item,--attributes,--environment, etc.). For long shorthand expressions the caret is the maindiagnostic for locating the mistake, so its loss makes these errors much
harder to act on.
Reproduction Steps
Any invalid shorthand value reproduces it; no credentials or API calls are
needed since parsing happens client-side:
Or directly against the parser:
Possible Solution
Move the placeholder into the f-string fragment in
ShorthandParseSyntaxError._construct_msg:This restores the pre-regression message byte-for-byte. The existing unit
tests only assert the exception type (
test_error_parsingintests/unit/test_shorthand.py), which is why this went unnoticed; a fixshould also add tests asserting the full message content, including the
caret position.
Additional Information/Context
DuplicateKeyInObjectErrormessages (duplicate shorthand keys) stillrender correctly and are unaffected.
shorthand.pyon thev2branch andis not affected.
_error_location,ShorthandParseSyntaxError, and related terms; no existing report found.Issue Bug on CLI input parsing #7502 mentions a shorthand error message but concerns a different
parsing bug (filed 2022, before this regression).
This report was generated with the assistance of AI tooling and reviewed by
Abuhaithem, per the repository's Automated Tools contribution guidelines.
CLI version used
aws-cli/1.45.40 (current
develop); regression present since 1.34.xEnvironment details (OS name and version, etc.)
All platforms (message construction is platform-independent); verified on Linux (kernel 6.17), Python 3.12