[SERVER-5978] Duplicate key error message contains incorrect error code after update Created: 31/May/12  Updated: 06/Dec/22  Resolved: 22/May/18

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.1.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aaron Heckmann Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OSX 10.7.4
MongoDB 2.1.1


Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

db.getPrevError() returns an object with an err message that includes the incorrect error code.

> db.x.drop()
> db.x.createIndex({ name: 1 }, { unique: 1 })
> db.x.insert({ name: 'aaron' })
> db.x.insert({ name: 'another' })
> db.x.update({ name: 'aaron' }, { $set: { name: 'another' }})
E11000 duplicate key error index: test.x.$name_1  dup key: { : "another" }
> db.getPrevError()
{
	"err" : "E11000 duplicate key error index: test.x.$name_1  dup key: { : \"another\" }",
	"code" : 11001,
	"n" : 0,
	"nPrev" : 1,
	"ok" : 1
}

Expected err message: "E11001 duplicate key error index: test.x.$name_1 dup key: { : \"another\" }"


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