Skip to main content

E11000 Duplicate Key Error

E11000 duplicate key error collection explained

Praise Magidi avatar
Written by Praise Magidi
Updated this week

Step

Buffer Destination

Message

E11000 duplicate key error collection: [database].[collection] index: id dup key: { id: ObjectId('[object_id]') }

Cause

This error occurs when there is an attempt to insert into a Buffer a record with an `_id` that already exists within the buffer. This might happen when taking records from one buffer and inserting them into another buffer, or when `_id` is being manually assigned.

Resolution

There are a few ways to resolve this issue:

1. Let the database assign the `_id` to the document being inserted into a Buffer. Remove the existing `_id` on the record before inserting, and the server will generate a valid, unique key (Recommended).

2. Create a new `ObjectID` before insertion by using the appropriate method available in a Calculator step. This ensures a unique identifier is generated programmatically, which can help prevent collisions.

Error Detail

{
"message": "E11000 duplicate key error collection: buffer.buffer611f6989ecb45515e7c16a33 index: id dup key: { id: ObjectId('67fe1588cb1c188XXXXXXXXXXX') }",
"errorMessage": "E11000 duplicate key error collection: buffer.buffer611f6989ecb45515e7c16a33 index: id dup key: { id: ObjectId('67fe1588cb1c188708444fa8') }",
"invalid": null,
"stepType": "Mapper",
"stepName": "Calculator",
"title": null,
"statusCode": 500,
"orgId": null,
"stepId": "836802b0-8d2c-4f96-9655-9555882faa59",
"mapStepId": "skMT8GWI-",
"mapStepPath": "vP-VE9RaUDh.skMT8GWI-",
"mapStepType": "Step"
"module": "Basic",
"commandProcessingError": null
}

Did this answer your question?