Skip to content

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

Merged
joshfried-aws merged 6 commits into
aws-cloudformation:mainfrom
joshfried-aws:main
Nov 28, 2023
Merged

joshfried-aws merged 6 commits into
aws-cloudformation:mainfrom
joshfried-aws:main

Conversation

@joshfried-aws

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

Copy link
Copy Markdown
Contributor

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

@Brianwithay21 Brianwithay21 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

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.

4 participants