From 9cca58746dcd1cb7729d9d518071b400d17e6abf Mon Sep 17 00:00:00 2001 From: Noah Stride Date: Fri, 22 Dec 2023 13:31:20 +0000 Subject: [PATCH] Correctly handle null/unknown convertion to BoolOption` --- terraform/tfschema/custom_types.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/terraform/tfschema/custom_types.go b/terraform/tfschema/custom_types.go index 2be695578..49b2f999b 100644 --- a/terraform/tfschema/custom_types.go +++ b/terraform/tfschema/custom_types.go @@ -60,8 +60,11 @@ func CopyFromBoolOption(diags diag.Diagnostics, tf attr.Value, o **apitypes.Bool diags.AddError("Error reading from Terraform object", fmt.Sprintf("Can not convert %T to types.Bool", tf)) return } - value := apitypes.BoolOption{Value: v.Value} - *o = &value + if !v.Null && !v.Unknown { + value := apitypes.BoolOption{Value: v.Value} + *o = &value + return + } } func CopyToBoolOption(diags diag.Diagnostics, o *apitypes.BoolOption, t attr.Type, v attr.Value) attr.Value {