[CDRIVER-1974] BSON_TYPE_CODE and BSON_TYPE_CODEWSCOPE fail to roundtrip through JSON correctly Created: 01/Jan/17 Updated: 08/Feb/17 Resolved: 04/Jan/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | json, libbson |
| Affects Version/s: | None |
| Fix Version/s: | 1.6.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Arseny Vakhrushev | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
Two BSON types, namely BSON_TYPE_CODE and BSON_TYPE_CODEWSCOPE, fail to transition through their JSON representation. In case of BSON_TYPE_CODE, its binary data will be different from the source document. That's especially weird because the JSON representation is restored with no difference. In case of BSON_TYPE_CODEWSCOPE, both the binary data and the JSON representation will be different from the source document when scope is an empty document (note the additional space between the scope brackets). When scope is not empty, the binary data will differ. Example:
Output:
|
| Comments |
| Comment by Arseny Vakhrushev [ 08/Feb/17 ] | ||||||||||||||||||||||
|
No prob. Will do. | ||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 08/Feb/17 ] | ||||||||||||||||||||||
|
Ah. Yeah, I didn't understand what issue you were reporting. If you'd like to report that we have a strange error message when parsing a top-level document with a $scope field, could you open a new issue that says exactly that please? | ||||||||||||||||||||||
| Comment by Arseny Vakhrushev [ 08/Feb/17 ] | ||||||||||||||||||||||
|
Hey Jesse. Well thanks for your answer! I am aware that these two JSONs aren't valid. The stress is on the error message actually, in particular, the difference between them. Let me try again. I know that this is invalid ...
... and I get what I deserve:
But when I add a scope (the whole thing is still invalid), ...
... I get something that I can't understand:
Hope it makes more sense now. Could be an indicator of some bug or at least some apparent inconsistency. | ||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 08/Feb/17 ] | ||||||||||||||||||||||
|
Hi Arseny. Code and Code With Scope types of elements of a BSON document. They can't stand alone. This works:
If that doesn't make sense, consider this question. Is this a JSON representation of a valid BSON document?:
No it isn't. Integers must be elements of a BSON document. This works:
Same with Code elements. | ||||||||||||||||||||||
| Comment by Arseny Vakhrushev [ 08/Feb/17 ] | ||||||||||||||||||||||
|
I didn't want to create a separate issue, but if I do this:
I get this:
What in the world is "Invalid state 1"? | ||||||||||||||||||||||
| Comment by Arseny Vakhrushev [ 04/Jan/17 ] | ||||||||||||||||||||||
|
Great news indeed! Thanks Jesse! I will be looking forward to the next release then. | ||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 04/Jan/17 ] | ||||||||||||||||||||||
|
Thanks for the report. Good news, this has already been fixed on master, as part of the JSONSL port and code with scope fixes ( | ||||||||||||||||||||||
| Comment by Arseny Vakhrushev [ 01/Jan/17 ] | ||||||||||||||||||||||
|
Happy new year lol! |