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

Add index name as a separate field on duplicate key error object

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.6.7, 3.0.4
    • 4.3.1
    • Usability
    • None
    • Fully Compatible
    • Execution Team 2019-07-01

    Description

      This issue is very similar to SERVER-5053, but focusing on the index field, not the duplicate keys.

      In other words, I'm not really so much interested in

      "key": { "_id" : ObjectId('4e683574bc4135eee514713f') }
      

      as I am in

      "index" : "test.people.$_id_"
      

      or better yet, fields like these:

      "ns": "test.people"
      "index" : "_id_"
      

      SERVER-5053 got closed as a duplicate of SERVER-4637 which doesn't even mention the index field, but suggests adding the keys as well as the _ids, which in turn resulted in some ambiguity on how to solve some problems that came up and the issue has been stalled since 2012.

      So, without getting bogged down by issues related to keys and _ids, would it be possible to just add the index name to the error object first and then figure out the rest later?

      I find nearly all of MongoDB's design and interfaces very elegant and pleasant to work with, but this is a major exception among the most common use cases. The duplicate key error message parsing is the messiest part of the Mongo interface in many applications.

      So this (hopefully simple) change would be a lot of help to many developers struggling with this problem.

      Attachments

        Issue Links

          Activity

            People

              maria.vankeulen@mongodb.com Maria van Keulen
              mjomble Andres Kalle
              Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: