Reputation: 13
I have recently upgraded parse-server to v4.2. I have also updated Mongo to v4.2 (It's a Replica Set configuration). Now when parse-server is raised, the following error appears "Unable to ensure uniqueness for user email addresses: Tried to ensure field uniqueness for a class that already has duplicates."
The detailed error is this:
{
"message": "Unable to ensure uniqueness for user email addresses: Tried to ensure field uniqueness for a class that already has duplicates.",
"code": 137,
"level": "warn",
"stack": "Error: Tried to ensure field uniqueness for a class that already has duplicates.\n at _adaptiveCollection.then.catch.error (/parse/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoStorageAdapter.js:569:15)\n at <anonymous>\n at process._tickDomainCallback (internal/process/next_tick.js:229:7)"
The error is caused by the _User
class that has the username and email fields with the same data.
Any ideas on how to fix the problem or make the parse-server not do this check.
Upvotes: 1
Views: 580
Reputation: 15072
The error message means that a unique index could not be created on the email
field.
The unique index ensures that in the email
field a value can only occur once, in other words, that it occurs uniquely. MongoDB cannot create such an index if there are already duplicate values in the email
field that would violate the rule of uniqueness, in other words, an identical email address already appears multiple times in the collection.
Keep in mind that Parse Server 4.0 introduced a case-insensitive index for the the field email
and username
. If you already have a user with email [email protected]
and another one with [email protected]
, the index creation will also fail.
The solution is to remove the duplicate email entries and restart Parse Server, so that index creation will be attempted again.
Upvotes: 0