Resolving Migration Error: Existing User Data Conflict

Overview

An error occurs during a custom database migration to Auth0 when the Import Users feature is enabled on an existing custom database connection. This issue happens when a user with an existing identity in Auth0 has conflicting user data in the legacy store. The system cannot automatically update the existing Auth0 user identity with the mismatched data during the import process.

Applies To
  • Database connection changes
  • User migration
  • Automatic migration
Cause

In a legacy authentication scenario, before the Import Users feature is enabled, a new user record is created within Auth0 during the user’s first login, but Auth0 does not store a hash of the user’s password. Auth0 will always use the legacy identity store and the identity it contains when authenticating the user.

 

The error occurs after the Import Users feature is enabled, due to a conflict existing between the data in the legacy store (for example, a new phone number) and the data in the Auth0 user record. The system cannot automatically resolve this data integrity conflict and rejects the database operation to prevent potential data corruption. 

Solution

Importing a user in this state requires a custom import script.

  1. Create a custom import script to import the user directly through the Management API.  The script should check the existing user record in Auth0 against the user identity being migrated from the legacy database.

  2. The script should modify the conflicting parameters from the legacy database profile to match the the existing user record in Auth0.  This will allow the user to be migrated, and the rest of the user's profile imported.

  3. After the user is migrated, the Auth0 user profile should then be updated with the conficting information from the legacy database using the Management API.

NOTE: Use the PATCH /v2/users/<id> endpoint to perform updates.

NOTE: The script must be for a single user profile or multiple user profiles have a record of what will need to be updated for each user after the script runs.

Recommended content

No recommended content found...