[SERVER-11966] getLastError includes "err" twice Created: 05/Dec/13  Updated: 05/Dec/13  Resolved: 05/Dec/13

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

Type: Bug Priority: Critical - P2
Reporter: A. Jesse Jiryu Davis Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-11955 getLastError response for failed inde... Closed
Operating System: ALL
Participants:

 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.



 Comments   
Comment by Scott Hernandez (Inactive) [ 05/Dec/13 ]

dup of SERVER-11955 (most likely)

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