CONNECTION_NOT_FOUND error during Bulk user import

Problem Statement

We received an error when using the bulk import job.

[
{
"code": "CONNECTION_NOT_FOUND",
"message": "The provided connection is not present on user <user>"
}
]

Cause

The CONNECTION_NOT_FOUND error is returned if the user is in the broken state (aka orphan user, ghost user) i.e. there is an applicationUser but no user profile.
https://github.com/auth0/auth0-users-lib/blob/fcdf177a15eeeb4263cdb66eff5497e246c8eb80/lib/users.bulk.js#L310-L324
https://github.com/auth0/auth0-users-lib/blob/fcdf177a15eeeb4263cdb66eff5497e246c8eb80/test/users.bulk.import.tests.js#L2161-L2196

Solution

If the affected users are confirmed to be orphan users, there are two methods to fix this problem:

  • Please delete the orphan users via the “Delete a connection user” endpoint of management API:
    Auth0 Management API v2
    This method applies if there are only a few orphan users.

  • Enable the flag import_user_repair_orphaned_users. It will automatically deletes the orphan user and does a regular user insertion. Please reach out to the Support team if you want to enable this flag.