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

[BugFix]: Gracefully handle keys for maps that are not of type string #418

Merged
merged 6 commits into from Nov 28, 2023

Conversation

joshfried-aws
Copy link
Contributor

@joshfried-aws joshfried-aws commented Nov 28, 2023

Issue #, if available:
N/A

Description of changes:
We have received a report about guard panicking when a key in a map isn't of type string. Our previous release had an oversight and we believed it was from an issue with nested maps only. Upon further investigation we realized this was not the case.

To remain consistent, we have decided to currently only allow for string types as keys for maps. If a template provides a key of a different type, cfn-guard will error out, and advise them of the issue.

An example error message looks like this:

Error occurred Parser Error when parsing `non string type detected for key in a map at L:7,C:30, cfn-guard only supports keys that are string types`

In addition to this, we also refactored our InternalError variant to be an enum itself, with 2 different variants currently. The 2 variants are InvalidKeyType and UnresolvedKeyForReporter


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Copy link
Member

@Brianwithay21 Brianwithay21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@joshfried-aws joshfried-aws merged commit 0ce8652 into aws-cloudformation:main Nov 28, 2023
8 checks passed
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.

None yet

4 participants