medusajs/medusa · error · MedusaError
Guest customer with this email already exists
Error message
Guest customer with this email already exists
What it means
Thrown when a guest customer record with the same email already exists (has_account=false) and the request supplies no authIdentityId — the workflow cannot disambiguate creating another guest for the same email.
Source
Thrown at packages/core/core-flows/src/customer/steps/validate-customer-account-creation.ts:56
}
// Check if customer with email already exists
const existingCustomers = await customerService.listCustomers({ email })
if (existingCustomers?.length) {
const hasExistingAccount = existingCustomers.some(
(customer) => customer.has_account
)
if (hasExistingAccount && input.authIdentityId) {
throw new MedusaError(
MedusaError.Types.DUPLICATE_ERROR,
"Customer with this email already has an account"
)
}
if (!hasExistingAccount && !input.authIdentityId) {
throw new MedusaError(
MedusaError.Types.DUPLICATE_ERROR,
"Guest customer with this email already exists"
)
}
}
}
)
View on GitHub (pinned to 5e06e544a2)
Solutions
- Supply the authIdentityId (register through an auth provider flow) so the existing guest is upgraded/linked instead of duplicated
- Delete or reuse the existing guest customer before retrying
- Handle DUPLICATE_ERROR and prompt the user to log in or reset
Example fix
// before
await createCustomerAccountWorkflow(container).run({
input: { customerData: { email } }, // no authIdentityId
})
// after
await createCustomerAccountWorkflow(container).run({
input: { customerData: { email }, authIdentityId },
}) Defensive patterns
Strategy: validation
Validate before calling
const [existing] = await customerService.listCustomers({ email })
if (existing && !existing.has_account && !authIdentityId) {
// reuse/upgrade the existing guest instead of creating another
} Try / catch
try { await createCustomerAccountWorkflow(scope).run({ input }) } catch (e) { if (e.type === MedusaError.Types.DUPLICATE_ERROR && /Guest/.test(e.message)) { /* attach authIdentityId or reuse guest */ } throw e } Prevention
- Always register through an auth provider so authIdentityId is present
- Reuse existing guest customer records for the same email
When it happens
Trigger: Calling createCustomerAccountWorkflow without authIdentityId when a guest customer with the same email was previously created (e.g. abandoned guest checkout).
Common situations: Guest checkout performed earlier with the same email, then account creation attempted without an auth identity; tests creating guest customers repeatedly with the same email fixture.
Related errors
- Customer with this email already has an account
- Email is required to create a customer
- Invalid step input
- Invalid step input
- Auth identity not found
AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27).
Data as JSON: /api/errors/6ece2d26ea01a76f.
Report an issue: GitHub.