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

insertMany result does not include server-side validation error information

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.2
    • Affects Version/s: 4.0.0
    • Component/s: None
    • Labels:
    • 2
    • Not Needed

      What problem are you facing?

      const { MongoClient } = require('mongodb');
      
      (async() => {
        const client = await MongoClient.connect('mongodb://localhost/');
        const db = client.db('testvalidation' + Date.now());
        const coll = await db.createCollection('contacts', {
          validator: {
            $and: [
              { phone: { $type: "string" } },
              { email: { $regex: /@mongodb\.com$/ } },
              { status: { $in: [ "Unknown", "Incomplete" ] } }
            ]
          }
        });
      
        try {
          await coll.insertOne({ email: "test@mongodb.com", status: "Unknown" });
        } catch (err) {
          console.dir(err, { depth: Infinity }); // err.errInfo.details.clausesNotSatisfied is helpful error information
        }
      
        try {
          await coll.insertMany([{ email: "test@mongodb.com", status: "Unknown" }]);
        } catch (err) {
          console.dir(err, { depth: Infinity }); // that information is missing here
        }
      
        await client.close();
      })();
      

      What driver and relevant dependency versions are you using?

      4.0.0 driver, 5.0.0 server

      Steps to reproduce?

      See above, information present for insertOne is missing from the insertMany result.

            Assignee:
            daria.pardue@mongodb.com Daria Pardue
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: