fix: allow the case of proto not found, such like gogo.proto (#2132)

Co-authored-by: Guoqiang Ding <guoqiang10@staff.sina.com.cn>
pull/2136/head
Guoqiang Ding 2 years ago committed by GitHub
parent a3439c9713
commit 2f8703bff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      api/metadata/server.go

@ -8,6 +8,7 @@ import (
"io"
"sync"
"github.com/go-kratos/kratos/v2/log"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@ -160,7 +161,8 @@ func allDependency(fd *dpb.FileDescriptorProto) ([]*dpb.FileDescriptorProto, err
for _, dep := range fd.Dependency {
fdDep, err := fileDescriptorProto(dep)
if err != nil {
return nil, err
log.Warnf("%s", err)
continue
}
temp, err := allDependency(fdDep)
if err != nil {
@ -188,7 +190,7 @@ func decompress(b []byte) ([]byte, error) {
func fileDescriptorProto(path string) (*dpb.FileDescriptorProto, error) {
fd, err := protoregistry.GlobalFiles.FindFileByPath(path)
if err != nil {
return nil, err
return nil, fmt.Errorf("find proto by path failed, path: %s, err: %s", path, err)
}
fdpb := protodesc.ToFileDescriptorProto(fd)
return fdpb, nil

Loading…
Cancel
Save