[CDRIVER-3387] libbson JSON parser interprets $type as legacy binary Created: 07/Oct/19  Updated: 30/Aug/22

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

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

Attachments: File repro.c    
Issue Links:
Related
related to CXX-2488 CSFLE badQueries and types errorConta... Closed

 Description   

The Extended JSON spec says:

A parser that accepts Legacy Extended JSON MUST be configurable such that a JSON text of a MongoDB query filter containing the type query operator can be parsed, e.g.:

{ "zipCode" : { $type : 2 } }
or:

{ "zipCode" : { $type : "string" } }

But libbson returns an error when parsing a $type in any of the JSON parsing functions:

  • bson_json_reader_read
  • bson_init_from_json
  • bson_new_from_json

Though it does accept the legacy binary format, e.g.

{ "$binary": "AQIDBAU=", "$type": "80" }

I see no way to configure parsing to interpret $type as just a normal key (not a legacy binary type).



 Comments   
Comment by Kevin Albertson [ 07/Jan/20 ]

Note, due to this bug, the client-side encryption tests had to omit the spec test badQueries.json. Once this is fixed, let's add back that test (and to C++ driver too).

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