Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fixed random failure of creating users in populatedb

NyanKiyoshi9ff0f90d8feb
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c659b0797d..b182071cfb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -77,6 +77,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Fixed the inability of users to set a variant's `priceOverride` and `costPrice` to `null` - #4754 by @NyanKiyoshi
- PaymentGatewayEnum removed from GraphQL schema as gateways now are dynamic plugins. Gateway names changed. - #4756 by @salwator
- Add support for webhooks - #4731 by @korycins
+- Fixed the random failure of `populatedb` trying to create a new user with an existing email - #4769 by @NyanKiyoshi
## 2.8.0
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index bd077afac1..c36101560c 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -353,6 +353,10 @@ def create_fake_user():
address = create_address()
email = get_email(address.first_name, address.last_name)
+ # Skip the email if it already exists
+ if User.objects.filter(email=email).exists():
+ return
+
user = User.objects.create_user(
first_name=address.first_name,
last_name=address.last_name,