[GODRIVER-1927] Unexpected characters are reported as invalid numbers Created: 21/Mar/21  Updated: 01/Aug/22

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

Type: Bug Priority: Minor - P4
Reporter: Oleg Pudeyev (Inactive) 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   

Problem Description

When I use mongodump with -q argument and I specify a timestamp and I add a closing parenthesis after the i value, I get an error message reading "invalid JSON number" when the number I provided is, as far as I can tell, perfectly valid and the problem is there are additional unexpected characters in input.

Steps to Reproduce

serene% ~me/debs/mongo/tools/mongodump  --port 14700   -q '{"ts":{"$timestamp":{"t":1578475955, "i":1)}}}' -c test -d ruby-driver        
2021-03-21T08:43:11.316-0400	Failed: error parsing query as Extended JSON: error decoding key ts: invalid JSON number. Position: 41

Expected Results

I expected the error message to reflect the actual error (unexpected ), unbalanced ), invalid syntax for a hash, etc.)

Actual Results

The error message complains about the integer being invalid.

Additional Notes



 Comments   
Comment by Oleg Pudeyev (Inactive) [ 22/Mar/21 ]

Ruby's BSON library reports an unexpected token (although without any description of which token is unexpected):

irb(main):006:0> BSON::ExtJSON.parse('{"ts":{"$timestamp":{"t":1578475955, "i":1)}}}')
Traceback (most recent call last):
        8: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `<main>'
        7: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `load'
        6: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        5: from (irb):5
        4: from (irb):6:in `rescue in irb_binding'
        3: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bson-4.12.0/lib/bson/ext_json.rb:58:in `parse'
        2: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:216:in `parse'
        1: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:216:in `parse'
JSON::ParserError (809: unexpected token at '{"ts":{"$timestamp":{"t":1578475955, "i":1)}}}')

irb(main):010:0> JSON.parse('{foo:1)}')
Traceback (most recent call last):
        6: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `<main>'
        5: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `load'
        4: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        3: from (irb):10
        2: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:216:in `parse'
        1: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:216:in `parse'
JSON::ParserError (809: unexpected token at '{foo:1)}')

Comment by Ryan Chipman [ 22/Mar/21 ]

moving this to the GODRIVER project, since extended JSON parsing is implemented in the driver, not in the tools themselves

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