Skip to content

Commit 2ee1a9a

Browse files
Only allow the strings 'true' and 'false' to pass the type checker
1 parent 078e63e commit 2ee1a9a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/tfbridge/typechecker/typechecker.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,15 @@ func (v *TypeChecker) validatePropertyValue(
161161

162162
switch typeSpec.Type {
163163
case "boolean":
164-
// The bridge permits the strings "true" and "false" to read as boolean, so allow strings.
165-
if !propertyValue.IsBool() && !propertyValue.IsString() {
164+
// Check for strings that are values "true" or "false".
165+
// These are handled as booleans in the bridge, so they should be skipped by the type checker.
166+
var boolString bool
167+
if propertyValue.IsString() {
168+
if propertyValue.StringValue() == "true" || propertyValue.StringValue() == "false" {
169+
boolString = true
170+
}
171+
}
172+
if !propertyValue.IsBool() && !boolString {
166173
return []Failure{newTypeFailure(propertyPath, typeSpec.Type, propertyValue)}
167174
}
168175
return nil

0 commit comments

Comments
 (0)