[CDRIVER-2223] JSON reader cannot parse integers for legacy $date syntax Created: 26/Jul/17  Updated: 28/Oct/23  Resolved: 27/Jul/17

Status: Closed
Project: C Driver
Component/s: json, libbson
Affects Version/s: None
Fix Version/s: 1.7.0

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Jeremy Mikola
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by PHPC-941 Introduce API for converting BSON to ... Closed
Related
is related to CDRIVER-2128 Support revised Extended JSON spec Closed

 Description   

933fd98 from CDRIVER-2128 removed the JSON reader's ability to parse legacy $date integers. Attempting to parse such dates now emits an error, such as:

Unexpected integer 1416445411987 in type "datetime"

We should revert that commit and add some tests for reading legacy values.



 Comments   
Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'jmikola', 'name': u'Jeremy Mikola', 'email': u'jmikola@gmail.com'}

Message:CDRIVER-2223: Parse integers for legacy JSON $date syntax

Since 933fd98107d11e2f9e516c229c7eb23dad941812, the JSON reader emitted an
error when encountering an integer value for a $date key. This restores the
previous behavior and allows legacy $date syntax to be parsed properly.
Consequently, a BSON corpus parse error test must now be skipped.

This commit adds previously absent tests for legacy $date syntax and adds
more valid and error cases to the existing $date $numberLong test.
Branch:r1.7
https://github.com/mongodb/libbson/commit/176b9c1489cb7452074550ef01ce1696f0e7c6ac

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'jmikola', 'name': u'Jeremy Mikola', 'email': u'jmikola@gmail.com'}

Message:CDRIVER-2225: Execute BSON corpus Decimal128 parse error tests

Since d7406f5dc010f4eb223c9eef8c144aa6efc33504, all parse error tests were
executing with bson_new_from_json(), which is only appropriate for type 0x00.

This commit also restructures the corpus test runner so that callbacks may be
provided for decode and parse error tests as they are for valid tests. This
change will make it easier to skip tests of any type, which will be necessary
for CDRIVER-2223.
Branch:r1.7
https://github.com/mongodb/libbson/commit/df2e61bd0bcf14b5e3b11ca7a74d509e08c72676

Comment by Jeremy Mikola [ 27/Jul/17 ]

Cherry-picked to r1.7: https://github.com/mongodb/libbson/commit/176b9c1489cb7452074550ef01ce1696f0e7c6ac

Comment by Githook User [ 27/Jul/17 ]

Author:

{'email': 'jmikola@gmail.com', 'username': 'jmikola', 'name': 'Jeremy Mikola'}

Message: CDRIVER-2223: Parse integers for legacy JSON $date syntax

Since 933fd98107d11e2f9e516c229c7eb23dad941812, the JSON reader emitted an
error when encountering an integer value for a $date key. This restores the
previous behavior and allows legacy $date syntax to be parsed properly.
Consequently, a BSON corpus parse error test must now be skipped.

This commit adds previously absent tests for legacy $date syntax and adds
more valid and error cases to the existing $date $numberLong test.
Branch: master
https://github.com/mongodb/libbson/commit/4affa6aa91ce896eca7f1b4326b49bcf1d0c16f5

Comment by Githook User [ 27/Jul/17 ]

Author:

{'email': 'jmikola@gmail.com', 'username': 'jmikola', 'name': 'Jeremy Mikola'}

Message: CDRIVER-2225: Execute BSON corpus Decimal128 parse error tests

Since d7406f5dc010f4eb223c9eef8c144aa6efc33504, all parse error tests were
executing with bson_new_from_json(), which is only appropriate for type 0x00.

This commit also restructures the corpus test runner so that callbacks may be
provided for decode and parse error tests as they are for valid tests. This
change will make it easier to skip tests of any type, which will be necessary
for CDRIVER-2223.
Branch: master
https://github.com/mongodb/libbson/commit/eaeb976736c0cbf290299dc6777f68a9ac2670c0

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