Skip to content

Commit d9f0da7

Browse files
authored
Fix panic for unknown and null values (#530)
1 parent 47711ed commit d9f0da7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

rules/aws_resource_missing_tags.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,12 @@ func stringInSlice(a string, list []string) bool {
379379
// If _any_ key is unknown, the entire value is considered unknown, since we can't know if a required tag might be matched by the unknown key.
380380
// Values are entirely ignored and can be unknown.
381381
func getKeysForValue(value cty.Value) (keys []string, known bool) {
382-
if !value.CanIterateElements() {
382+
if !value.CanIterateElements() || !value.IsKnown() {
383383
return nil, false
384384
}
385+
if value.IsNull() {
386+
return keys, true
387+
}
385388

386389
return keys, !value.ForEachElement(func(key, _ cty.Value) bool {
387390
// If any key is unknown or sensitive, return early as any missing tag could be this unknown key.

rules/aws_resource_missing_tags_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ rule "aws_resource_missing_tags" {
406406
Expected: helper.Issues{},
407407
},
408408
{
409-
Name: "Unkown value maps should be silently ignored",
409+
Name: "Unknown value maps should be silently ignored",
410410
Content: `variable "aws_region" {
411411
default = "us-east-1"
412412
type = string

0 commit comments

Comments
 (0)