-
Type: Bug
-
Resolution: Done
-
Priority: Trivial - P5
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
Currently passing a MongoDB connection URI with the "connect" option causes an exception due to the option validator. The exception occurs even with the warn option set to True since TypeErrors are not caught.
Since any value passed to the URI options are parsed as a string, when the "connect" option is validated with validate_boolean it cannot be valid since the value will always be a string.
This should be fixed by changing the validator used for the "connect" option from validate_boolean to validate_boolean_or_string which is already present.
Reproduce Steps (from IPython
In [1]: from pymongo import MongoClient In [2]: cx = MongoClient('mongodb://localhost/?connect=true') TypeError: connect must be True or False In [3]: cx = MongoClient('mongodb://localhost/?connect=1') TypeError: connect must be True or False In [4]: cx = MongoClient('mongodb://localhost/?connect=False') TypeError: connect must be True or False
If there is a reason that "connect" must be validated in this way, it would be helpful to add a comment for why "connect" is the only option with the strict boolean validator.