Consider a compound index with a name:
A duplicate key error on that index reports this errmsg:
The dup key is a string that looks like JSON but is missing the field names. It would be easier for clients to understand the error message if the dup key contained the field names as well as the values, especially in the case of named indexes where the index name doesn't provide enough of a clue, e.g.
I'd also prefer that the index name be rendered without the collection name or the $. Clients know what collection they are using. and the $ is not part of the index name from the clients perspective.