From 706b9b2a09bd3ce2c100d731d30780fd7c710849 Mon Sep 17 00:00:00 2001 From: Anil Date: Fri, 7 Jul 2023 20:52:01 +0200 Subject: [PATCH] catch error if type is missing --- cmd/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/config.go b/cmd/config.go index 5266a4685..9888a4596 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -19,6 +19,7 @@ package cmd import ( "context" "encoding/json" + "errors" "fmt" "io" "io/ioutil" @@ -393,7 +394,11 @@ func UnmarshalJSONProviderConfig(data []byte, customTypes map[string]reflect.Typ return nil, err } - typeName := m["type"].(string) + typeName, ok := m["type"].(string) + if !ok { + return nil, errors.New("cannot find type"); + } + var provCfg provider.ProviderConfig if ty, found := customTypes[typeName]; found { provCfg = reflect.New(ty).Interface().(provider.ProviderConfig)