NoValidConnectionsError not raised when socket.getaddrinfo() fails as a direct cause of client.connect()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9.9k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
Documentation for the NoValidConnectionsError states that:
This exception class wraps multiple “real” underlying connection errors, all of which represent failed connection attempts. Because these errors are not guaranteed to all be of the same error type (i.e. different errno, socket.error subclass, message, etc) we expose a single unified error message and a None errno so that instances of this class match most normal handling of socket.error objects.
IOW it wraps all various kinds of socket errors. However, this doesn't include calls to getaddrinfo in the _self._families_and_addresses method. IMO issuing getaddr is an inherent part of establishing connection and hence socket.gaierror exceptions should be wrapped like any other exception coming from socket.socket. This forces library users to handle both types of errors not just NoValidConnectionsError which is IMO in contradiction to the docs linked above since from client's POV both exceptions came from the same library (paramiko in this case).
To provide a bit more background, I'm using paramiko to test whether a fresh VM I created is ready to be connected to over SSH. It takes a little while until the VM reaches a state where the network is up and the VM got a DHCP lease, so naturally getaddr must fail, but that is expected, it doesn't change anything on the fact, that gaierror caused as part of client.connect should not be wrapped with NoValidConnectionsError.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Paramiko's client.connect flow and the _self._families_and_addresses method named in the report. Compare the documented NoValidConnectionsError behavior with socket.getaddrinfo() failures, then add regression coverage showing the intended exception from client.connect and run the relevant test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100