[SERVER-29676] arrayToObject should not error out on explicit value of null for value Created: 15/Jun/17  Updated: 30/Oct/23  Resolved: 22/Jun/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.5.6
Fix Version/s: 3.4.6, 3.5.10

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Tess Avitabile (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v3.4
Sprint: Query 2017-07-10
Participants:

 Description   

If my object is o:{ "foo": null } and {$objectToArray:"$o"} converts it to {k:"foo",v:null} then $arrayToObject must be able to convert it back to the object, but instead it gives the error:

Error: command failed: {
	"ok" : 0,
	"errmsg" : "$arrayToObject requires an object with keys 'k' and 'v'. Missing either or both keys from: {k: \"comment\", v: null}",
	"code" : 40393,
	"codeName" : "Location40393"
}

Explicit null is a different type than missing, so we're probably checking for "nullish" when we should be checking for "missing".



 Comments   
Comment by Githook User [ 27/Jun/17 ]

Author:

{u'username': u'sindbach', u'name': u'Wan Bachtiar', u'email': u'sindbach@gmail.com'}

Message: SERVER-29676 arrayToObject should not error out on explicit value of null or undefined for value

Closes #1158

Signed-off-by: Tess Avitabile <tess.avitabile@mongodb.com>
(cherry picked from commit 21f0ae2d10531d0897c55c7be16f783abb6a8e1d)
Branch: v3.4
https://github.com/mongodb/mongo/commit/7bb1b5f71c2b7b48802ef5b41860713e2add25e0

Comment by Githook User [ 22/Jun/17 ]

Author:

{u'username': u'sindbach', u'name': u'Wan Bachtiar', u'email': u'sindbach@gmail.com'}

Message: SERVER-29676 arrayToObject should not error out on explicit value of null or undefined for value

Closes #1158

Signed-off-by: Tess Avitabile <tess.avitabile@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/21f0ae2d10531d0897c55c7be16f783abb6a8e1d

Comment by Asya Kamsky [ 15/Jun/17 ]

I believe the test on this line:

https://github.com/mongodb/mongo/blob/9822df6e71b0c5793676f9358e5d212c103c19a7/src/mongo/db/pipeline/expression.cpp#L612

should be !value.missing() and not !value.nullish()

Generated at Thu Feb 08 04:21:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.