[CDRIVER-2802] match_bson_with_ctx behavior is inconsistent Created: 24/Aug/18 Updated: 28/Oct/23 Resolved: 04/Dec/18 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | tests |
| Affects Version/s: | None |
| Fix Version/s: | 1.14.0 |
| Type: | Improvement | Priority: | Trivial - P5 |
| Reporter: | Kevin Albertson | Assignee: | Samantha Ritter (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | FY2019Q4 Quick Wins (C and CXX) |
| Description |
|
match_bson_with_ctx is used during testing to compare a BSON document against a pattern. If it fails, it aborts, unless the caller has passed in a context object with certain fields set. This behavior is subtle and undocumented. Instead, match_bson_with_ctx should not abort, and callers of match_bson should always check its return value for success or failure. |
| Comments |
| Comment by Githook User [ 04/Dec/18 ] |
|
Author: {'name': 'samantharitter', 'email': 'samantha.ritter@10gen.com', 'username': 'samantharitter'}Message: |
| Comment by Samantha Ritter (Inactive) [ 12/Nov/18 ] |
|
I have done an audit of the match_bson_* methods. I found that most of the time, these methods will abort() if there is no match. However, there are two ways these methods will return false without aborting: 2. If the caller calls match_bson_with_ctx with an error message. If match_bson_with_ctx is called without an error message (for example, if you call it through match_bson) then we call test_error and abort. If you do pass an error message, though, we will print it and return false instead. In my opinion this behavior is misleading and inconsistent. These methods should be changed to always abort when there is no match, or always return false without aborting. |