-
Notifications
You must be signed in to change notification settings - Fork 298
fix: handle peer-info validation errors #887
Conversation
BREAKING CHANGE. Previously swarm.peers would throw an uncaught error if any peer in the reponse could have its peerId or multiaddr validated. This PR catches errors that occur while validating the peer info. The returned array will contain an entry for every peer in the ipfs response. peer-info objects that couldn't be validated, now have an `error` property and a `rawPeerInfo` property. This at least means the count of peers in the response will be accurate, and there the info is available to the caller. This means that callers now have to deal with peer-info objects that may not have a `peer or `addr` property. Adds `nock` tests to exercice the code under different error conditions. Doing so uncovered a bug in our legacy go-ipfs <= 0.4.4 peer info parsing, which is also fixed. The code was trying to decapusalate the peerId from the multiaddr, but doing so trims the peerId rather than returning it. fixes #885 License: MIT Signed-off-by: Oli Evans <[email protected]>
This also fixes ipfs/ipfs-webui#878 |
I need to figure out how to tell ageir to only run the |
@olizilla Remove the |
License: MIT Signed-off-by: Oli Evans <[email protected]>
License: MIT Signed-off-by: Oli Evans <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Do you have a moment to PR https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmpeers to make a note of the change?
@alanshaw related to our conversations about the multiaddr validation problem, I found this multiformats/multiaddr#70 |
js-ipfs-api can encounter individual peer info objects that have newer multiaddrs or, in theory, a new format for PeerId that it cannot parse. Allowing for individiual peerInfo validation errors allows us to return a response which has the right number of peers in, and peerId and multiaddr info for all the other peers that could be validated, along with a info about peers that failed to validate. See: ipfs-inactive/js-ipfs-http-client#887
The There is a PR to update the interface-core spec here ipfs-inactive/interface-js-ipfs-core#393 |
js-ipfs-api can encounter individual peer info objects that have newer multiaddrs or, in theory, a new format for PeerId that it cannot parse. Allowing for individiual peerInfo validation errors allows us to return a response which has the right number of peers in, and peerId and multiaddr info for all the other peers that could be validated, along with a info about peers that failed to validate. See: ipfs-inactive/js-ipfs-http-client#887
License: MIT Signed-off-by: Alan Shaw <[email protected]>
BREAKING CHANGE. Previously swarm.peers would throw an uncaught error
if any peer in the reponse couldn't have its peerId or multiaddr validated.
This PR catches errors that occur while validating the peer info. The
returned array will contain an entry for every peer in the ipfs response.
peer-info objects that couldn't be validated, now have an
error
propertyand a
rawPeerInfo
property. This at least means the count of peers inthe response will be accurate, and there the info is available to the caller.
This means that callers now have to deal with peer-info objects that may
not have a
peer
oraddr
property.Adds
nock
tests to exercice the code under different error conditions.Doing so uncovered a bug in our legacy go-ipfs <= 0.4.4 peer info parsing,
which is also fixed. The code was trying to decapusalate the peerId from
the multiaddr, but doing so trims the peerId rather than returning it.
fixes #885
License: MIT
Signed-off-by: Oli Evans [email protected]