CSHARP-5930: [Tiny] Fix unreliable DNS lookup#1970
Open
ajcvickers wants to merge 1 commit intomongodb:mainfrom
Open
CSHARP-5930: [Tiny] Fix unreliable DNS lookup#1970ajcvickers wants to merge 1 commit intomongodb:mainfrom
ajcvickers wants to merge 1 commit intomongodb:mainfrom
Conversation
The test URL uses `mongodb+srv://`, which causes MongoClientSettings.FromUrl to call url.Resolve() at line 904, which does a real DNS TXT lookup for awssessiontokentest.example.net. That domain doesn't exist, so DNS times out. The test was introduced in 2020 and has always made a real DNS call. Whether it passes depends entirely on how the local DNS resolver handles the awssessiontokentest.example.net query: - Your machine: DNS query for example.net times out (your resolver sends it upstream and waits). - CI (and possibly many other environments): The DNS server quickly returns NXDOMAIN for .example.net — it's an IANA-reserved domain under RFC 2606, and many resolvers short-circuit it. When NXDOMAIN comes back fast, DnsClient does not throw DnsResponseException for a "timed out or transient error" — it returns an empty response, GetTxtRecords returns an empty list, and GetResolvedOptionsFromTxtRecords on an empty list succeeds silently. The fix is to change `mongodb+srv://` to `mongodb://` — the SRV scheme is irrelevant to what the test verifies (credential parsing), and it's the only reason any DNS call happens at all.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an unreliable unit test in MongoClientSettingsTests by removing the use of the mongodb+srv:// scheme, which triggers a real DNS TXT lookup during MongoClientSettings.FromUrl parsing and can intermittently time out depending on the environment’s DNS behavior.
Changes:
- Update the AWS credential parsing test connection string from
mongodb+srv://tomongodb://to avoid SRV/TXT DNS resolution during the test.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The test URL uses
mongodb+srv://, which causes MongoClientSettings.FromUrl to call url.Resolve() at line 904, which does a real DNS TXT lookup for awssessiontokentest.example.net. That domain doesn't exist, so DNS times out. The test was introduced in 2020 and has always made a real DNS call. Whether it passes depends entirely on how the local DNS resolver handles the awssessiontokentest.example.net query:mongodb+srv://tomongodb://— the SRV scheme is irrelevant to what the test verifies (credential parsing), and it's the only reason any DNS call happens at all.