From 76a669a2098a8da25d64f034fe2123d8f1ce8451 Mon Sep 17 00:00:00 2001 From: kushalshit27 <43465488+kushalshit27@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:31:32 +0530 Subject: [PATCH 1/2] fix auth_form expand interface array --- internal/auth0/form/expand.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/internal/auth0/form/expand.go b/internal/auth0/form/expand.go index 3bcbfadc..28bbc29f 100644 --- a/internal/auth0/form/expand.go +++ b/internal/auth0/form/expand.go @@ -108,28 +108,20 @@ func expandInterfaceArray(d *schema.ResourceData, key string) []interface{} { return result } - if oldMetadata == "" { - if newMetadataStr, ok := newMetadata.(string); ok { - var newMetadataArr []interface{} - if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil { - return nil - } - return newMetadataArr - } - return result - } - if newMetadata == "" { return result } - b, err := json.Marshal(newMetadata) - if err != nil { - return nil + if newMetadataStr, ok := newMetadata.(string); ok { + var newMetadataArr []interface{} + if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil { + return nil + } + return newMetadataArr } - if err := json.Unmarshal(b, &result); err != nil { - return nil + if newMetadataArr, ok := newMetadata.([]interface{}); ok { + return newMetadataArr } return result From 40fff8a4e69dc691f698be858d3f64dec3c5efd6 Mon Sep 17 00:00:00 2001 From: kushalshit27 <43465488+kushalshit27@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:13:49 +0530 Subject: [PATCH 2/2] fix auth_flow expand interface array --- internal/auth0/flow/expand.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/internal/auth0/flow/expand.go b/internal/auth0/flow/expand.go index 64588ebf..c1a5fd66 100644 --- a/internal/auth0/flow/expand.go +++ b/internal/auth0/flow/expand.go @@ -75,28 +75,20 @@ func expandInterfaceArray(d *schema.ResourceData, key string) []interface{} { return result } - if oldMetadata == "" { - if newMetadataStr, ok := newMetadata.(string); ok { - var newMetadataArr []interface{} - if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil { - return nil - } - return newMetadataArr - } - return result - } - if newMetadata == "" { return result } - b, err := json.Marshal(newMetadata) - if err != nil { - return nil + if newMetadataStr, ok := newMetadata.(string); ok { + var newMetadataArr []interface{} + if err := json.Unmarshal([]byte(newMetadataStr), &newMetadataArr); err != nil { + return nil + } + return newMetadataArr } - if err := json.Unmarshal(b, &result); err != nil { - return nil + if newMetadataArr, ok := newMetadata.([]interface{}); ok { + return newMetadataArr } return result