-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Unknown
-
Affects Version/s: 4.12
-
Component/s: None
-
None
-
None
-
Python Drivers
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
In the current version of PyMongo, when using a mongodb+srv connection string, the driver throws an error if the hostname used for SRV resolution is identical to one of the resolved hostnames, even when the hostname contains three or more dot-separated parts.
According to the MongoDB Initial DNS Seedlist Discovery specification, the requirement that returned hostnames contain an additional domain level applies only when the SRV hostname has fewer than three dot-separated parts. When the SRV hostname has three or more dot-separated parts, it is valid for the returned hostnames to be identical.
This behavior causes valid configurations to fail and appears to contradict the intended logic in the specification.
Steps to Reproduce:
1. Create an SRV record with a hostname containing three dot-separated parts (e.g., cluster.example.com).
2. Configure the SRV record to point to one or more hostnames that are identical to the original (e.g., cluster.example.com).
3. Attempt to connect to MongoDB using PyMongo with a mongodb+srv connection string.
Expected Behavior:
The connection should succeed, as the resolved hostnames are valid according to the specification (they are identical and contain three dot-separated parts).
Actual Behavior:
The connection fails with the following error: pymongo.errors.ConfigurationError: Invalid SRV host: return address is identical to SRV hostname.
This suggests that PyMongo is incorrectly applying the “must have an additional domain level” rule even when it is not required by the specification.
Environment:
• PyMongo Version: 4.12.0
• Python Version: 3.13.2
• Operating System: Linux ubuntu-24-04 6.8.0-57-generic aarch64
Additional Notes:
This behavior seems to be a misapplication of the hostname validation rule and may prevent valid configurations from working. If this is an intentional change, clarification in the documentation would be appreciated. Otherwise, it appears to be a bug that should be corrected.
- split to
-
DRIVERS-3162 Add test for SRV hostname validation when resolver and resolved hostnames are identical with three domain levels
-
- In Review
-