[CDRIVER-3389] Duplicate authMechanismProperties should be consistent with other duplicate URI options Created: 09/Oct/19  Updated: 27/Oct/23  Resolved: 06/Dec/21

Status: Closed
Project: C Driver
Component/s: docs, libmongoc, uri
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Roberto Sanchez
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Duplicates for values within authMechanismProperties have surprisingly different behavior from how other duplicate URI options are handled. For example, the following produces no warning:

example-client mongodb://u:p@localhost/?authMechanismProperties=SERVICE_NAME:a,SERVICE_NAME:b

Additionally, unlike other URI options, since authMechanismProperties are stored without duplicate checking, when they're retrieved (e.g. here) we'll use the first occurrence ("a" in the example above) which differs from other URI duplicate options handling where we will use the value of the last occurrence and warn. E.g.

example-client "mongodb://localhost/?serverSelectionTimeoutMS=1000&serverSelectionTimeoutMS=500"

Produces a warning:

2019/10/09 12:32:43.0476: [49764]:  WARNING:       mongoc: Overwriting previously provided value for 'serverSelectionTimeoutMS'

And would use the value 500.

Note, I think this is technically spec-compliant since duplicate URI options is undefined.

Note, the auth spec says:

Naming of mechanism properties MUST be case-insensitive. For instance, SERVICE_NAME and service_name refer to the same property.



 Comments   
Comment by Roberto Sanchez [ 06/Dec/21 ]

Updated the documentation to reflect that this particular issue (specifying the same key multiple times) results in undefined behavior.

Comment by Kevin Albertson [ 14/Oct/19 ]

Since this is undefined by the spec, this could be a documentation only change.

Comment by Kevin Albertson [ 09/Oct/19 ]

Note, this check needs to be made case insensitive as well, since the properties are stored as they are presented.

Generated at Wed Feb 07 21:17:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.