Bulk User Import and Lazy Migration

Problem Statement

When bulk importing users from a legacy database connection, we noticed a lot of DUPLICATED_USERS errors even when sending the user_id and the “upsert” value as true .

Symptoms

  • DUPLICATED_USERS error for some users when using the bulk user import endpoint of the Mgmt API sending the user_id and upsert=true
  • If the user_id is not sent on the JSON payload, a duplicate user is created
  • CONFLICT_USERNAME if tenant flag import_user_match_user_profile_on_user_id is set
  • Custom db with import mode on

Steps to reproduce

  • Log a user in through a custom DB with import mode off
  • Turn import mode on and import the user through the Management API

Cause

Using both types of migration, lazy migration and bulk user imports, can result in this error when trying to import users that logged in before turning import mode on. This creates a partial user record in Auth0 that causes the duplicated user error.

Solution

The only workaround currently is to delete the users with the users endpoint in order to remove the incomplete record from Auth0.