-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
-
ALL
-
-
Sharding EMEA 2022-03-07
The following code shows the appropriate error messages when used with Mongo 5.2:
>>> from pymongo import InsertOne, DeleteOne, ReplaceOne >>> from pymongo.errors import BulkWriteError >>> requests = [ ... InsertOne({'_id': 1}), ... DeleteOne({'_id': 2}), ... InsertOne({'_id': 3}), ... ReplaceOne({'_id': 4}, {'i': 1})] >>> try: ... db.test.bulk_write(requests, ordered=False) ... except BulkWriteError as bwe: ... pprint(bwe.details) {'nInserted': 0, 'nMatched': 1, 'nModified': 1, 'nRemoved': 1, 'nUpserted': 0, 'upserted': [], 'writeConcernErrors': [], 'writeErrors': [{'code': 11000, 'errmsg': 'E11000 duplicate key error collection: ' 'bulk_example.test index: _id_ dup key: { _id: 1 }', 'index': 0, 'keyPattern': {'_id': 1}, 'keyValue': {'_id': 1}, 'op': {'_id': 1}}, {'code': 11000, 'errmsg': 'E11000 duplicate key error collection: ' 'bulk_example.test index: _id_ dup key: { _id: 3 }', 'index': 2, 'keyPattern': {'_id': 1}, 'keyValue': {'_id': 3}, 'op': {'_id': 3}}]}
When using Mongo Latest in Evergreen, we get the following output (note the empty errmsg in the second error object):
{'nInserted': 0, 'nMatched': 1, 'nModified': 1, 'nRemoved': 1, 'nUpserted': 0, 'upserted': [], 'writeConcernErrors': [], 'writeErrors': [{'code': 11000, 'errmsg': 'E11000 duplicate key error collection: ' 'bulk_example.test index: _id_ dup key: { _id: 1 }', 'index': 0, 'keyPattern': {'_id': 1}, 'keyValue': {'_id': 1}, 'op': {'_id': 1}}, {'code': 11000, 'errmsg': '', 'index': 2, 'keyPattern': {'_id': 1}, 'keyValue': {'_id': 3}, 'op': {'_id': 3}}]}
- causes
-
CSHARP-4083 TestInsertBatchContinueOnError failing on latest
- Closed
-
PHPC-2075 Bulk write test failures due to missing error messages on "latest" server version
- Blocked
- is caused by
-
SERVER-63331 Use a proper IDL structure for the write commands' error reporting
- Closed