Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4016

NULL-reference error if a property in MapReduce `scope` is `null`

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.3.1
    • Component/s: CRUD

      What problem are you facing?

      Passing null as a value of a property of the scope object in mapReduce() ends with a NULL-reference error:

       

      TypeError: Cannot read properties of null (reading '_bsontype')
          at processScope (.\node_modules\mongodb\lib\operations\map_reduce.js:157:29)
      

       

      What driver and relevant dependency versions are you using?

      4.3.1

      Steps to reproduce?

      const { MongoClient } = require("mongodb");
      const uri = "mongodb://127.0.0.1/";
      const client = new MongoClient(uri);
      async function run() {
        try {
          await client.connect();
          const database = client.db('test');
          const test = database.collection('test');
          await test.mapReduce(null, null, {scope: {test: null}, out: 'inline'});
        } finally {
          await client.close();
        }
      }
      run().catch(console.dir);
      

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            lukasz@walukiewicz.eu Łukasz Walukiewicz
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: