From 70ded839f75bca1e39af6b87c107f756bce30b2b Mon Sep 17 00:00:00 2001 From: Nathan Baulch Date: Thu, 19 Sep 2024 15:07:35 +1000 Subject: [PATCH] Extract all form fields even if some fail --- encoding/form/proto_encode.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/encoding/form/proto_encode.go b/encoding/form/proto_encode.go index 67b92f92737..ea40d32c363 100644 --- a/encoding/form/proto_encode.go +++ b/encoding/form/proto_encode.go @@ -21,10 +21,7 @@ func EncodeValues(msg interface{}) (url.Values, error) { if v, ok := msg.(proto.Message); ok { u := make(url.Values) err := encodeByField(u, "", v.ProtoReflect()) - if err != nil { - return nil, err - } - return u, nil + return u, err } return encoder.Encode(msg) } @@ -56,7 +53,6 @@ func encodeByField(u url.Values, path string, m protoreflect.Message) (finalErr list, err := encodeRepeatedField(fd, v.List()) if err != nil { finalErr = err - return false } for _, item := range list { u.Add(newPath, item) @@ -67,7 +63,6 @@ func encodeByField(u url.Values, path string, m protoreflect.Message) (finalErr m, err := encodeMapField(fd, v.Map()) if err != nil { finalErr = err - return false } for k, value := range m { u.Set(fmt.Sprintf("%s[%s]", newPath, k), value) @@ -81,13 +76,11 @@ func encodeByField(u url.Values, path string, m protoreflect.Message) (finalErr } if err = encodeByField(u, newPath, v.Message()); err != nil { finalErr = err - return false } default: value, err := EncodeField(fd, v) if err != nil { finalErr = err - return false } u.Set(newPath, value) }