fix(cometbft/grpc): gRPC path parsing (#22081)

This commit is contained in:
testinginprod
2024-10-03 11:26:58 +00:00
committed by GitHub
parent 30003f6679
commit e914910b02
2 changed files with 7 additions and 4 deletions
+2
View File
@@ -100,6 +100,8 @@ func makeUnknownServiceHandler(handlers map[string]appmodulev2.Handler, querier
if err != nil {
return fmt.Errorf("failed to get registry: %w", err)
}
method = strings.TrimPrefix(method, "/")
fullName := protoreflect.FullName(strings.ReplaceAll(method, "/", "."))
// get descriptor from the invoke method
desc, err := registry.FindDescriptorByName(fullName)
+5 -4
View File
@@ -245,12 +245,13 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq
return nil, false, err
}
path := strings.TrimPrefix(req.Path, "/")
pathFullName := protoreflect.FullName(strings.ReplaceAll(path, "/", "."))
// in order to check if it's a gRPC query we ensure that there's a descriptor
// for the path, if such descriptor exists, and it is a method descriptor
// then we assume this is a gRPC query.
fullName := protoreflect.FullName(strings.ReplaceAll(req.Path, "/", "."))
desc, err := registry.FindDescriptorByName(fullName)
desc, err := registry.FindDescriptorByName(pathFullName)
if err != nil {
return nil, false, err
}
@@ -262,7 +263,7 @@ func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryReq
handler, found := c.queryHandlersMap[string(md.Input().FullName())]
if !found {
return nil, true, fmt.Errorf("no query handler found for %s", fullName)
return nil, true, fmt.Errorf("no query handler found for %s", req.Path)
}
protoRequest := handler.MakeMsg()
err = gogoproto.Unmarshal(req.Data, protoRequest) // TODO: use codec