From 2fdb37963ed81d6bf33031522a5261948ec73586 Mon Sep 17 00:00:00 2001 From: Gian <105635829+glcbrg@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:27:10 +0100 Subject: [PATCH] fix: additional check on flatType func to avoid crash --- utils/misc.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/misc.go b/utils/misc.go index 1a5ec39..64f4719 100644 --- a/utils/misc.go +++ b/utils/misc.go @@ -69,7 +69,9 @@ func Md5File(filename string) (string, error) { // FlatStruct tries to flat a struct object in a map[string]string func FlatStruct(s interface{}) map[string]string { flatten := make(map[string]string) - flatType(s, "", flatten) + if s != nil { + flatType(s, "", flatten) + } return flatten } @@ -79,6 +81,9 @@ func flatType(s interface{}, prefix string, flatten map[string]string) { if kind == reflect.Ptr || kind == reflect.Interface { v = reflect.Indirect(v) kind = v.Kind() + if kind == reflect.Invalid { + return + } } t := v.Type()