Skip to content

Commit a40eb33

Browse files
authored
Fix panic message to show correct unhandled type rather than the parent type (#969)
I was trying to model a block that had `map[string][]string` as it's schema, but the code was panicking with: ``` Unknown validation type: 6 ``` Debugging, and it became clear that non-primitive types are not supported in the switch, but I was puzzled as to why it was reporting that a `TypeMap` was not a valid map value. The switch is against `valueType`, so it makes sense (to me at least) that the panic should report that as the unknown validation type. With this change, the code would report: ``` Unknown validation type: 7 ``` Where 7 equates to `TypeSet` (aka. the string slice value of the map)
1 parent a34f8f0 commit a40eb33

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

helper/schema/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ func validateMapValues(k string, m map[string]interface{}, schema *Schema, path
21342134
})
21352135
}
21362136
default:
2137-
panic(fmt.Sprintf("Unknown validation type: %#v", schema.Type))
2137+
panic(fmt.Sprintf("Unknown validation type: %#v", valueType))
21382138
}
21392139
}
21402140
return diags

0 commit comments

Comments
 (0)