Reputation: 1
In my DNS nameserver list e.g. nameservers: ['255.255.255.255', '255.255.255.0', ''] there is a blank entry. I am in an enterprise with no ability to remove the blank entry. dnspython.resolver treats this blank as an error even though there are also good entries and pymongo responds to the error by not launching and showing this error pymongo.errors.ConfigurationError: nameserver is not a dns.nameserver.Nameserver instance or text form, IP address, nor a valid https URL
. The dnspython team have offered this fix:
from typing import Dict, List, Sequence, Union
import dns.resolver
class EmptyOkResolver(dns.resolver.Resolver):
@classmethod
def _enrich_nameservers(
cls,
nameservers: Sequence[Union[str, dns.nameserver.Nameserver]],
nameserver_ports: Dict[str, int],
default_port: int,
) -> List[dns.nameserver.Nameserver]:
nameservers = [x for x in nameservers if x]
return super()._enrich_nameservers(nameservers, nameserver_ports, default_port)
dns.resolver.OriginalResolver = dns.resolver.Resolver
dns.resolver.Resolver = EmptyOkResolver
dns.resolver.reset_default_resolver()
But should this fix go in the pymongo somewhere? How to get that done?
I tried raising this with dnspython (https://github.com/rthalley/dnspython/pull/1092#issuecomment-2168814193) but this was not successful as they view this as an error.. I would like to continue to use pymongo and therefore their dependency on dnspython but with my peculiar situation and having no ability to change the DNS list to remove the blank value, I am stumped. I tried downgrading to dnspython 2.1.0 and this fixes the problem but I am required to use a newer version because of security concerns. Open to suggestions.
Upvotes: 0
Views: 70