fix(cometbft/grpc): gRPC path parsing (#22081)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user