[SERVER-25192] Object.extend doesn't handle null properties Created: 21/Jul/16  Updated: 08/Jan/24  Resolved: 26/Jul/16

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: None
Fix Version/s: 3.2.13, 3.3.11

Type: Bug Priority: Major - P3
Reporter: Tim Sogard Assignee: Mira Carey
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.2, v3.0
Sprint: Platforms 18 (08/05/16)
Participants:
Linked BF Score: 0

 Description   

Ran into this issue adapting mongo-perf to run some internal bench marks. A query op such as this:

ops : [
  { op: "find",
    ns: "app-test.emails",
    query: {
      accountId: "12345-67890-12345-67890",
      _type: { $ne: null }
    }
  }
]

produces the following error:

Error running test [object Object]: Cannot use 'in' operator to search for 'floatApprox' in null:TypeError: Cannot use 'in' operator to search for 'floatApprox' in null
at Function.Object.extend (src/mongo/shell/types.js:228:34)
at Function.Object.extend (src/mongo/shell/types.js:231:28)
at Function.Object.extend (src/mongo/shell/types.js:231:28)
at util/utils.js:86:29
at Array.forEach (native)
at runTest (util/utils.js:82:14)
at runTests (util/utils.js:369:38)
at mongoPerfRunTests (util/utils.js:421:19)
at (shell):1:1

The issue is that in javascript:

[00:09:51] tim@Timo:~/src/mongo $ node
> typeof(null)
'object'

and the code being modified in the PR is trying to deep copy an object, verifying the property is an object by using typeof().



 Comments   
Comment by Githook User [ 10/Apr/17 ]

Author:

{u'username': u'drags', u'name': u'Tim Sogard', u'email': u'tim+git@lever.co'}

Message: SERVER-25192 Handle null properties in Object.extend

Closes #1103

(cherry picked from commit ad5040e94641e0dcfccbd1d415520281618afde8)
Branch: v3.2
https://github.com/mongodb/mongo/commit/15d286b971df65e58184643a031bbe579ac040a5

Comment by Ramon Fernandez Marina [ 30/Jul/16 ]

Thank you for your contribution tim@lever.co, looking forward to the next one

Regards,
Ramón.

Comment by Tim Sogard [ 27/Jul/16 ]

Hey Ramón,

I actually read over the testing section of the CONTRIBUTING.rst doc, but convinced myself the change was too trivial to warrant a test. Makes sense that one would be warranted for a change to the Object prototype.

Thank you to everyone involved for a speedy consideration and merging of the change. I really appreciate it.

Cheers,
Tim

Comment by Ramon Fernandez Marina [ 27/Jul/16 ]

tim@lever.co, I take you've seen that Jason has added a test to your pull request and merged it into the master branch. With some exceptions, changes have to be accompanied by tests that cover the changes made in the pull request – now you know for future contributions

Thanks again for taking the time to submit a pull request.

Regards,
Ramón.

Comment by Githook User [ 26/Jul/16 ]

Author:

{u'username': u'drags', u'name': u'Tim Sogard', u'email': u'tim+git@lever.co'}

Message: SERVER-25192 Handle null properties in Object.extend

Closes #1103
Branch: master
https://github.com/mongodb/mongo/commit/ad5040e94641e0dcfccbd1d415520281618afde8

Comment by Ramon Fernandez Marina [ 21/Jul/16 ]

tim@lever.co, this ticket is to handle your pull request. Sending to the platforms team for evaluation.

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