[SERVER-19281] Add index name as a separate field on duplicate key error object Created: 04/Jul/15  Updated: 24/Jul/19  Resolved: 25/Jun/19

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: 2.6.7, 3.0.4
Fix Version/s: 4.3.1

Type: Improvement Priority: Major - P3
Reporter: Andres Kalle Assignee: Maria van Keulen
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DRIVERS-712 Add index name as a separate field on... Closed
Documented
is documented by DOCS-12910 Investigate changes in SERVER-19281: ... Closed
Duplicate
is duplicated by SERVER-3069 Add extra fields to getLastError outp... Closed
is duplicated by SERVER-33814 Include additional metadata as proper... Closed
Related
related to SERVER-27021 add index name to duplicate record er... Closed
related to SERVER-4637 E11000 (duplicate key error) should r... Open
related to SERVER-3372 Allow indexing fields of arbitrary le... Closed
related to SERVER-14543 Display _id of document that fails in... Closed
is related to SERVER-14801 duplicate key error should report fie... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2019-07-01
Participants:

 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.



 Comments   
Comment by Githook User [ 25/Jun/19 ]

Author:

{'name': 'Maria van Keulen', 'username': 'mvankeulen94', 'email': 'maria@mongodb.com'}

Message: SERVER-19281 Add ns and index fields to DuplicateKey getLastErrorObj
Branch: master
https://github.com/mongodb/mongo/commit/2fcd19c930a516653a46c25fa533071ccee1d741

Comment by Maria van Keulen [ 24/Jun/19 ]

Re-opening, since SERVER-37070 actually doesn't address the request for this information to exist outside of the "err" string.

Comment by Maria van Keulen [ 24/Jun/19 ]

It looks like this has been resolved for all storage engines as of SERVER-37070. Closing as Done.

Generated at Thu Feb 08 03:50:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.