Yaml: handle type error due to invalid content (#14964)
Some checks failed
Release / call-build-workflow (push) Has been cancelled
Release / Publish Docker :release (push) Has been cancelled
Release / Github & APT (push) Has been cancelled
Release / Demo (push) Has been cancelled
Release / Hassio Addon (push) Has been cancelled

This commit is contained in:
andig 2024-07-22 09:01:17 +02:00 • committed by GitHub
parent 5d540f6a02
commit 5083645b95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@ import (
"cmp"
"encoding/json"
"errors"
"fmt"
"io"
"reflect"
"slices"
@ -200,7 +201,7 @@ func DecodeOtherSliceOrMap(other, res any) error {
if typ := reflect.TypeOf(other); typ.Kind() == reflect.Slice || typ.Kind() == reflect.Map {
len = reflect.ValueOf(other).Len()
} else {
panic("invalid kind: " + typ.Kind().String())
return fmt.Errorf("cannot decode into slice or map: %v", other)
}
if len == 0 {