The syntax used for representing HostPorts (as parsed here: https://github.com/mongodb/mongo/blob/master/src/mongo/util/net/hostandport.h#L209) is ambiguous with respect to IPv6 addresses.
For example, ::1:1234 could either mean host ::1:1234, port unspecified, or host ::1, port 1234. The code in hostport.h will serialise both of these forms into the same syntax, but will always parse using the latter interpretation.
This creates problems for drivers, which need to be able to correctly parse things like the hosts in the ismaster response, which are representing using this serialised form.
Proposal: IPv6 addresses must be wrapped in square brackets in HostAndPort strings that do have a terminal :port part, and maybe at other times. HostAndPort::host will return the string without the square brackets, but when serializing HostAndPort to a string, the square brackets will be placed around the address portion. So,