URI validation
I was building the URI in a spring configuration file as
spring.data.mongodb.uri=${MONGODB_URI}/test?retryWrites=true&w=majority
where MONGODB_URI came from a kubernetes secret (as it contains user & password)
somehow a new-line had slipped into the kubernetes secret, so the query was effectively asking for "fpos-dev-pl-1.kqybg.mongodb.net\n"
Besides learning how to correctly configure secrets, I learned in the process that neither Spring nor mongo was validating that spring.data.mongodb.uri was a well-formed URI and the application failed to start with error messages relating to not finding DNS and not being able to resolve the TXT record. This was very confusing.
The driver should accept a URI parameter (instead of a String) and ensures that it is valid.