Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-25192

Object.extend doesn't handle null properties

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.13, 3.3.11
    • Affects Version/s: None
    • Component/s: JavaScript
    • None
    • Fully Compatible
    • ALL
    • v3.2, v3.0
    • Platforms 18 (08/05/16)
    • 0

      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().

            Assignee:
            mira.carey@mongodb.com Mira Carey
            Reporter:
            tim@lever.co Tim Sogard
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: