diff --git a/internal/cli/server/api_service.go b/internal/cli/server/api_service.go index 3781b6b45d..5af1a4adf6 100644 --- a/internal/cli/server/api_service.go +++ b/internal/cli/server/api_service.go @@ -49,6 +49,10 @@ func (s *Server) HeaderByNumber(ctx context.Context, req *protobor.GetHeaderByNu return nil, err } + if header == nil { + return nil, errors.New("header not found") + } + return &protobor.GetHeaderByNumberResponse{Header: headerToProtoborHeader(header)}, nil } @@ -62,6 +66,10 @@ func (s *Server) BlockByNumber(ctx context.Context, req *protobor.GetBlockByNumb return nil, err } + if block == nil { + return nil, errors.New("block not found") + } + return &protobor.GetBlockByNumberResponse{Block: blockToProtoBlock(block)}, nil }