Skip to content

Fix #3991: Quote number-like strings in CloudFormation templates#10050

Open
Ashutosh0x wants to merge 1 commit intoaws:developfrom
Ashutosh0x:fix/issue-3991-yaml-string-quoting
Open

Fix #3991: Quote number-like strings in CloudFormation templates#10050
Ashutosh0x wants to merge 1 commit intoaws:developfrom
Ashutosh0x:fix/issue-3991-yaml-string-quoting

Conversation

@Ashutosh0x
Copy link

This PR fixes issue #3991 where strings like '1e10' or '0755' were being output without quotes by 'aws cloudformation package', causing them to be misinterpreted as numbers when re-parsed.

I've added a custom string representer to yaml_dump in yamlhelper.py that identifies and quotes ambiguous strings (scientific notation, octal, hex, binary, and sexagesimal formats).

Tests added:

  • Comprehensive unit tests in ests/unit/customizations/cloudformation/test_yamlhelper.py covering various edge cases.
  • Verified that existing CloudFormation tests still pass.

Fixes #3991

This fixes a long-standing issue where strings like '1e10' or '0755'
were being output without quotes by 'aws cloudformation package',
causing them to be misinterpreted as numbers when re-parsed.

Added a custom string representer to yaml_dump that identifies and
quotes ambiguous strings (scientific notation, octal, hex, binary,
and sexagesimal formats).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws cloudformation package breaks certain string literals in templates

1 participant