[GODRIVER-1512] Legacy $regex extended JSON not parsed Created: 03/Mar/20  Updated: 30/Mar/22

Status: Backlog
Project: Go Driver
Component/s: JSON & ExtJSON
Affects Version/s: 1.3.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: David Golden Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Improve JSON & ExtJSON Implementation

 Description   

The driver fails to parse the legacy regular expression type of this document:

{"":{"$regex":"","$options":""}}

Output (hex form):

280000000300210000000224726567657800010000000002246f7074696f6e730001000000000000

Other examples:

{"":{"$regex":"abc","$options":"i"}}
2c0000000300250000000224726567657800040000006162630002246f7074696f6e73000200000069000000
{"":{"$options":"i","$regex":"abc"}}
2c00000003002500000002246f7074696f6e7300020000006900022472656765780004000000616263000000
 
// These should error due to the extra key
{"":{"$regex":"abc","$options":"i","0":""}}
3400000003002d0000000224726567657800040000006162630002246f7074696f6e730002000000690002300001000000000000
{"":{"$options":"i","$regex":"abc","0":""}}
3400000003002d00000002246f7074696f6e73000200000069000224726567657800040000006162630002300001000000000000



 Comments   
Comment by Divjot Arora (Inactive) [ 17/Mar/20 ]

Thanks for the information. I was under the impression that we don't support the legacy binary format, but I found the special-cased code to add support for it. Given that, I agree this ticket makes sense. Moving from "Investigating" to "In Progress".

EDIT: Moving from "Investigating" to the backlog to concentrate on other things for the 1.3.2 and 1.4.0 releases.

Comment by David Golden [ 17/Mar/20 ]

The legacy $binary format is already supported by the driver:

{"":{"$binary":"//8=","$type":"0"}}
0e00000005000200000000ffff00

Similarly, in GODRIVER-742, the decision was made to accept a legacy format.

I think the driver shouldn't selectively support legacy types, as that's going to lead to user confusion.

Comment by Divjot Arora (Inactive) [ 17/Mar/20 ]

david.golden My understanding is that the driver's extjson library does not support the legacy format and we don't have plans to support it right now. The extjson spec also says "A parser MAY also accept strings that adhere to other formats, such as Legacy Extended JSON formats emitted by old versions of mongoexport or other tools, but only if explicitly configured to do so." Given that, adding support for the legacy format would require adding another variable or function for users to opt into it. Am I missing something? 

Generated at Thu Feb 08 08:36:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.