[GODRIVER-1551] Allow BSON undefined to decode to Go types Created: 03/Apr/20  Updated: 28/Oct/23  Resolved: 08/Apr/20

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 1.3.1
Fix Version/s: 1.4.0

Type: Improvement Priority: Minor - P4
Reporter: David Golden Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends

 Description   

The driver already allows decoding BSON Null as an integer type and it should do the same for the BSON Undefined type.

This caused an error in ADL because the shell's `db.stats()` command sends the `scale` parameter as BSON undefined, which was not coerced to an integer but failed decoding instead:

> db.stats()
{
        "ok" : 0,
        "errmsg" : "failed to parse command: cannot decode undefined into an integer type, correlationID = 16025a5ab6004ec18d14584f",
        "code" : 9,
        "codeName" : "FailedToParse"
}



 Comments   
Comment by Githook User [ 08/Apr/20 ]

Author:

{'name': 'Divjot Arora', 'email': 'divjot.arora@10gen.com', 'username': 'divjotarora'}

Message: GODRIVER-1551 Allow BSON undefined values to decode into Go types (#360)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/7019e82e76c06ff1dc764557000112c8b6fc485b

Comment by Divjot Arora (Inactive) [ 08/Apr/20 ]

https://github.com/mongodb/mongo-go-driver/pull/360

Comment by Benjamin Flast [ 03/Apr/20 ]

Yes, 1.4.0 should be fine.  We expect db.stats() to be used more heavily through ADL when a new Atlas feature called Online Archive comes out, and that will be coming out at a similar time to 4.4 Server.

Comment by David Golden [ 03/Apr/20 ]

I think 1.4.0 timeframe is fine.  +benjamin.flast can comment further.

The problem is that "db.stats()" apparently is a not-uncommon thing for people to run to see "what's in my database" and so it's a bad early user-experience.  Fixing this in ADL would mean having to duplicate a lot of the driver's existing "convert X to int" code, so we'd rather see this fixed driver-side, where it seems to be mostly a matter of adding an extra case statement to the existing value decoders (plus tests).

Comment by Craig Wilson [ 03/Apr/20 ]

Yeah... I don't really remember the context or which way I argued, but I do think this now a request we've received and is needed. The shell sends undefined, so, while deprecated, is still in use even by us.

Comment by Divjot Arora (Inactive) [ 03/Apr/20 ]

I'm inclined to change this to a feature request. The work to allow BSON null values to decode into non-pointer types was done in GODRIVER-1175. In that PR, we discussed allowing undefined as well, but decided against it because we had not received any requests to do it and it is a deprecated BSON type.

CC craiggwilson You brought up the possibility of handling undefined in the original PR. Any thoughts here?

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