From 2ee1a9ad22d7ba42197817243b4fb90f355154c2 Mon Sep 17 00:00:00 2001 From: guineveresaenger Date: Mon, 28 Oct 2024 15:33:07 -0700 Subject: [PATCH] Only allow the strings 'true' and 'false' to pass the type checker --- pkg/tfbridge/typechecker/typechecker.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/tfbridge/typechecker/typechecker.go b/pkg/tfbridge/typechecker/typechecker.go index 3a96a4101..e61e013e4 100644 --- a/pkg/tfbridge/typechecker/typechecker.go +++ b/pkg/tfbridge/typechecker/typechecker.go @@ -161,8 +161,15 @@ func (v *TypeChecker) validatePropertyValue( switch typeSpec.Type { case "boolean": - // The bridge permits the strings "true" and "false" to read as boolean, so allow strings. - if !propertyValue.IsBool() && !propertyValue.IsString() { + // Check for strings that are values "true" or "false". + // These are handled as booleans in the bridge, so they should be skipped by the type checker. + var boolString bool + if propertyValue.IsString() { + if propertyValue.StringValue() == "true" || propertyValue.StringValue() == "false" { + boolString = true + } + } + if !propertyValue.IsBool() && !boolString { return []Failure{newTypeFailure(propertyPath, typeSpec.Type, propertyValue)} } return nil