From c04499239706b503a8d74aaa12f1d0c75db372ab Mon Sep 17 00:00:00 2001 From: Srevin Saju Date: Wed, 6 Dec 2023 18:09:20 +0300 Subject: [PATCH] fix: check if the list or map is empty, and use Emptylist and emptyObjects instead --- internal/blocks/data/terraform.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/blocks/data/terraform.go b/internal/blocks/data/terraform.go index c983dac..4f2475c 100644 --- a/internal/blocks/data/terraform.go +++ b/internal/blocks/data/terraform.go @@ -280,8 +280,16 @@ func getObjectType(m map[string]interface{}) map[string]cty.Value { } typeOf := typeRaw.Kind() if typeOf == reflect.Map { + if len(v.(map[string]interface{})) == 0 { + s[k] = cty.ObjectVal(map[string]cty.Value{}) + continue + } s[k] = cty.ObjectVal(getObjectType(v.(map[string]interface{}))) } else if typeOf == reflect.Slice { + if len(v.([]interface{})) == 0 { + s[k] = cty.ListValEmpty(cty.String) + continue + } s[k] = cty.ListVal(getListType(v.([]interface{}))) } else { impliedType, err := gocty.ImpliedType(v)