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

bulkWrite() in mongo shell does not check updates start with '$' and replacements do not

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Shell
    • Labels:
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      The following should all throw a JavaScript exception without executing the command on the server:

      db.mycoll.bulkWrite([{replaceOne: {filter: {}, replacement: {$set: {a: 1}}}}])
      db.mycoll.bulkWrite([{updateOne: {filter: {}, update: {field: 1}}}])
      db.mycoll.bulkWrite([{updateMany: {filter: {}, update: {field: 1}}}])
      

      Show
      The following should all throw a JavaScript exception without executing the command on the server: db.mycoll.bulkWrite([{replaceOne: {filter: {}, replacement: {$set: {a: 1}}}}]) db.mycoll.bulkWrite([{updateOne: {filter: {}, update: {field: 1}}}]) db.mycoll.bulkWrite([{updateMany: {filter: {}, update: {field: 1}}}])

      Description

      DBCollection.prototype.replaceOne() validates the replacement document contains at least one non-$operator field. DBCollection.prototype.updateOne() and DBCollection.prototype.updateMany() validate the update object contains at least one $operator field.

      However, none of replaceOne, updateOne, or updateMany in DBCollection.prototype.bulkWrite() do the same.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-stm Backlog - Server Tooling and Methods (STM)
              Reporter:
              max.hirschhorn Max Hirschhorn
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: