User Import Fails with Error: "Error in passwordHash Property - String does not Match Pattern"

Problem statement

We ran a bulk import of user data using Create import users job(/api/v2/jobs/users-imports). We have completed an Import Job with success, but some of the data has errors. One error what we are seeing is as follow:

"Error in passwordHash property - String does not match pattern ^\\$2[ab]?\\$10+\\$[./A-Za-z0-9]{53}$"

How can we resolve this error?

Cause

The error message “Error in passwordHash property - String does not match pattern ^\$2[ab]?\$10+\$[./A-Za-z0-9]{53}$”, is indicating that the password_hash value for a user did not pass a regex validation.

Solution

Per the JSON user schema for imports the password_hash must be a string and should be hashed using bcrypt $2a$ or $2b$ and have 10 saltRounds:

"password_hash": {
	"type": "string",
	"description": "Hashed password for the user. Passwords should be hashed using bcrypt $2a$ or $2b$ and have 10 saltRounds."
}