Update typeurl to v2.2.2

Fixes panic when typeurl is not found

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2024-11-04 22:29:24 -08:00
parent 18caa33fdc
commit ff09b428e1
4 changed files with 10 additions and 12 deletions

View File

@@ -284,16 +284,14 @@ func getTypeByUrl(url string) (reflect.Type, error) {
mu.RUnlock()
mt, err := protoregistry.GlobalTypes.FindMessageByURL(url)
if err != nil {
e := protoregistry.NotFound
if !errors.Is(err, e) {
return nil, fmt.Errorf("type with url %s: %w", url, ErrNotFound)
}
for _, h := range handlers {
if t := h.GetType(url); t != nil {
return t, nil
if errors.Is(err, protoregistry.NotFound) {
for _, h := range handlers {
if t := h.GetType(url); t != nil {
return t, nil
}
}
}
return nil, fmt.Errorf("type with url %s: %w", url, ErrNotFound)
}
empty := mt.New().Interface()
return reflect.TypeOf(empty).Elem(), nil