[CDRIVER-3723] Validate URI options on client/client pool creation Created: 18/Jun/20 Updated: 28/Oct/23 Resolved: 04/Jan/22 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | 1.21.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Kevin Albertson | Assignee: | Jeremy Mikola |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
URI options may be passed to a mongoc_uri_t in three ways. 1. Through the string passed to the mongoc_uri_new call.
mongoc_uri_finalize_tls, mongoc_uri_finalize_auth, mongoc_uri_finalize_directconnection validate other state of URI options. It is only called for (1). Options set by (2) may not undergo validation unless they validated from options being applied by (3). URI options should be validated regardless of how options are set. The proposed solution is to validate URI options on client/client pool construction by introducing the new APIs:
|
| Comments |
| Comment by Githook User [ 04/Jan/22 ] | |||||
|
Author: {'name': 'Jeremy Mikola', 'email': 'jmikola@gmail.com', 'username': 'jmikola'}Message: Introduces new mongoc_client_new_from_uri_with_error and mongoc_client_pool_new_with_error methods. Also addresses topology leak in mongoc_client_new_from_uri (
This no longer requires constructing a client and expecting an error through server selection.
Moving the check up from _mongoc_client_new_from_topology makes mongoc_client_new_from_uri_with_error consistent with mongoc_client_pool_new_with_error. Additionally, we add log message assertions to corresponding tests.
These tests were previously introduced in
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com> | |||||
| Comment by Jeremy Mikola [ 23/Dec/21 ] | |||||
| Comment by Kevin Albertson [ 02/Sep/20 ] | |||||
|
Hi pierremickael.gonzalo@gmail.com, with the new proposed APIs, the mongoc_uri_t is still created and parsed before the client. Avoiding double validation is a good point. Internally, the mongoc_uri_t could track whether options were set after the initial parsing to avoid an unnecessary revalidation when constructing the client.
Setting options via TXT records is referencing the Initial DNS Seedlist Discovery specification. That sets additional options after a DNS lookup of TXT records, and has additional constraints. I'm removing the new-eng label from this ticket. I think this may require some more involved restructuring of mongoc-uri.c parsing. | |||||
| Comment by Pierre Mickael GONZALO [ 07/Aug/20 ] | |||||
|
Hi, I have a question about the new prototype function of the two news api: So the uri argument would be still not initialized when calling those apis ?
you mean : initialize directly a mongoc_uri_t and set its attribute str ? So the thing is to call "mongoc_uri_parse" is these new api to validate URI options ? |