libp2p / go-libp2p-routing-helpers

MIT License
11 stars 16 forks source link

fix: handle err with response #81

Closed aschmahmann closed 1 year ago

aschmahmann commented 1 year ago

fixes https://github.com/ipfs/kubo/issues/10117

cc @Jorropo another fun bug here where if the response from functions like FindPeer is both an error and a value we don't return an error (even if the value is a peer.AddrInfo with no addresses). I'm not sure what the intended behavior was here with IgnoreError, empty, etc. on functions like FindPeer, so please check my work.

Note: you could also argue that the code here should be fine and that the issue is in implementations like https://github.com/libp2p/go-libp2p-kad-dht/blob/b63ad6096833d36b365f1361edab871f6cdc283c/dual/dual.go#L304

Additionally, if preferred (or additionally) we could change: https://github.com/libp2p/go-libp2p-routing-helpers/blob/71d7c965185ed346e39cc26140ac49ea13b2222f/compparallel.go#L143

to check addr.ID == "" || len(addr.Addrs) == 0 so that we check more rigorously for an empty result.