-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: Connection String & URI Options, URI Options
-
None
-
None
-
Rust Drivers
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
Problem
ConnectionString::parse returns two TLS conflict errors as ordinary string literals. The brace placeholders are shown to the caller instead of the option name and value.
The returns are in driver/src/client/options.rs, parse_option_pair, on the tls / ssl arm. Nearby TLS errors in the same function already use format!.
Repro
- mongodb://localhost/?tlsCAFile=/tmp/ca.pem&tls=false
- mongodb://localhost/?tlsInsecure=true&tls=false
- mongodb://localhost/?tls=false&ssl=true
Options are applied left to right, and a key may appear only once. tlsCAFile or tlsInsecure turns TLS on before tls=false. tls=false then ssl=true hits the other arm, because tls and ssl are different keys.
Actual:
cannot set {key}={tls} if other TLS options are set
cannot set {key}={tls} if TLS is disabled
Expected:
cannot set tls=false if other TLS options are set cannot set ssl=true if TLS is disabled
Fix
Interpolate key and value in those two errors, and assert the full message. The existing tls_insecure test only checked for the substrings "other TLS options are set" and "TLS is disabled", which are present in the uninterpolated literals, so it did not catch this.
Follow-up: the options parser needs a broader cleanup
This ticket fixes only the TLS messages. parse_option_pair is still a hand-maintained match, and the "did you mean" list URI_OPTIONS is a second list that has drifted from it:
- Parsed, but missing from URI_OPTIONS, so a typo gets a weak or wrong suggestion: loadbalanced, srvmaxhosts, enableoverloadretargeting, tlscertificatekeyfilepassword.
- URI_OPTIONS lists uuidRepresentation in camel case. Keys are lowercased before the Jaro-Winkler comparison.
- adaptiveretries is in URI_OPTIONS, and its parser arm is commented out, so a near-miss can suggest an option the parser will not accept.
driver/src/client/options.rs is about 3,500 lines. A follow-up should replace the parallel list and match with one option table (name, parser, feature gate) that both parses and suggests, and should fail a test if an arm is missing from that table.