Skip to content

Commit

Permalink
add check for length
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlavanet committed Sep 25, 2024
1 parent 51c3f3b commit 41f8a94
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions protocol/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ func ParseBlockHashFromReplyAndDecode(rpcInput RPCInput, resultParser spectypes.
return "", err
}

if len(parsedBlockHashes) == 0 {
return "", utils.LavaFormatError("[ParseBlockHashFromReplyAndDecode] failed to fetch block hashes from parsed input, len(parsedBlockHashes) == 0", nil, utils.LogAttr("rpcInput.GetResult()", rpcInput.GetResult()))
numberOfParsedHashes := len(parsedBlockHashes)
if numberOfParsedHashes != 1 {
return "", utils.LavaFormatError("[ParseBlockHashFromReplyAndDecode] expected parsed hashes length 1", nil, utils.LogAttr("rpcInput.GetResult()", rpcInput.GetResult()), utils.LogAttr("hashes_length", numberOfParsedHashes))
}
return parseResponseByEncoding([]byte(parsedBlockHashes[0]), resultParser.Encoding)
}
Expand Down

0 comments on commit 41f8a94

Please sign in to comment.