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

getLastError includes "err" twice

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Critical - P2 Critical - P2
    • None
    • None
    • None
    • None
    • ALL

    Description

      In 2.5.4:

      > db.collection.insert({_id:1})
      > db.collection.insert({_id:1})
      E11000 duplicate key error index: test.collection.$_id_  dup key: { : 1.0 }
      > db.getLastErrorObj()
      {
              "err" : "E11000 duplicate key error index: test.collection.$_id_  dup key: { : 1.0 }",
              "code" : 11000,
              "n" : 0,
              "connectionId" : 1,
              "ok" : 1
      }

      In nightly, git hash ed76da14b4:

      > db.collection.insert({_id:1})
      > db.collection.insert({_id:1})
      E11000 duplicate key error index: test.collection.$_id_  dup key: { : 1.0 }
      > db.getLastErrorObj()
      {
              "err" : "E11000 duplicate key error index: test.collection.$_id_  dup key: { : 1.0 }",
              "code" : 11000,
              "n" : 0,
              "connectionId" : 13,
              "syncMillis" : 0,
              "writtenTo" : null,
              "err" : "E11000 duplicate key error index: test.collection.$_id_  dup key: { : 1.0 }",
              "ok" : 1
      }

      The shell prints "err" with the error message twice, but this is bogus. What the server actually returns is more like:

      {
              "err" : "E11000 duplicate key error index: test.collection.$_id_  dup key: { : 1.0 }",
              "code" : 11000,
              "n" : 0,
              "connectionId" : 13,
              "syncMillis" : 0,
              "writtenTo" : null,
              "err" : null,
              "ok" : 1
      }

      The shell responds by printing the first "err" value twice. PyMongo responds by using only the second value, null, which makes it think there's no last error at all.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: