[SERVER-11903] Remove BSONElement::validate() Created: 29/Nov/13 Updated: 11/Jul/16 Resolved: 03/Jan/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 2.4.8 |
| Fix Version/s: | 2.5.5 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | James Wahlin | Assignee: | Mathias Stearn |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Minor Change | ||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
Original title: BSONElement.validate() success on invalid BSON There have been cases where BSONElement.validate() fails to recognize that an element is invalid. In the following code in tool.cpp we see the following:
When we have a corrupt BSONElement, BSONElement.validate() should recognize and throw an exception. |
| Comments |
| Comment by Githook User [ 06/Jan/14 ] |
|
Author: {u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: Not using the passed-in fieldname invalidated the ErrorIsInId test case. |
| Comment by Githook User [ 06/Jan/14 ] |
|
Author: {u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: Fixes a bug in implementation of |
| Comment by Mathias Stearn [ 03/Jan/14 ] |
|
Only backwards breaking for C++ driver users calling this function. |
| Comment by Githook User [ 03/Jan/14 ] |
|
Author: {u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}Message: It was mostly used for improving the error messages about BSON that already |
| Comment by Mathias Stearn [ 23/Dec/13 ] |
|
Decision: kill BSONElement::validate() as described in my last comment. Will also look over validateBSON error messaging and make sure it provides enough information in the cases where we are using BSONElement::validate() today. |
| Comment by Mathias Stearn [ 19/Dec/13 ] |
|
There are a total of 5 places in the current codebase that call BSONElement::validate(). Other than in BSONObj::toString() they all follow the pattern of checking BSONObj::valid (which is just a wrapper around validateBSON) then on failure, checking BSONElement::validate() to provide more information in the error message. Those uses should be easy to change, assuming validateBSON can provide the needed information. I think the call in BSONObj::toString() should just be deleted since it doesn't seem necessary. |