Commit 8a792bbc authored by hannahhoward's avatar hannahhoward

fix(message): check for nil selector

check for nil selector in a request and error if it is present
parent df4a18b1
...@@ -259,9 +259,13 @@ func (gsm *graphSyncMessage) ToProto() (*pb.Message, error) { ...@@ -259,9 +259,13 @@ func (gsm *graphSyncMessage) ToProto() (*pb.Message, error) {
pbm := new(pb.Message) pbm := new(pb.Message)
pbm.Requests = make([]pb.Message_Request, 0, len(gsm.requests)) pbm.Requests = make([]pb.Message_Request, 0, len(gsm.requests))
for _, request := range gsm.requests { for _, request := range gsm.requests {
selector, err := ipldutil.EncodeNode(request.selector) var selector []byte
if err != nil { var err error
return nil, err if request.selector != nil {
selector, err = ipldutil.EncodeNode(request.selector)
if err != nil {
return nil, err
}
} }
pbm.Requests = append(pbm.Requests, pb.Message_Request{ pbm.Requests = append(pbm.Requests, pb.Message_Request{
Id: int32(request.id), Id: int32(request.id),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment