{"record":{"id":"6ece2d26ea01a76f","repo":"medusajs/medusa","slug":"guest-customer-with-this-email-already-exists","errorCode":null,"errorMessage":"Guest customer with this email already exists","messagePattern":"Guest customer with this email already exists","errorType":"exception","errorClass":"MedusaError","httpStatus":400,"severity":"error","filePath":"packages/core/core-flows/src/customer/steps/validate-customer-account-creation.ts","lineNumber":56,"sourceCode":"    }\n\n    // Check if customer with email already exists\n    const existingCustomers = await customerService.listCustomers({ email })\n\n    if (existingCustomers?.length) {\n      const hasExistingAccount = existingCustomers.some(\n        (customer) => customer.has_account\n      )\n\n      if (hasExistingAccount && input.authIdentityId) {\n        throw new MedusaError(\n          MedusaError.Types.DUPLICATE_ERROR,\n          \"Customer with this email already has an account\"\n        )\n      }\n\n      if (!hasExistingAccount && !input.authIdentityId) {\n        throw new MedusaError(\n          MedusaError.Types.DUPLICATE_ERROR,\n          \"Guest customer with this email already exists\"\n        )\n      }\n    }\n  }\n)\n","sourceCodeStart":38,"sourceCodeEnd":64,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/core-flows/src/customer/steps/validate-customer-account-creation.ts#L38-L64","documentation":"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.","triggerScenarios":"Calling createCustomerAccountWorkflow without authIdentityId when a guest customer with the same email was previously created (e.g. abandoned guest checkout).","commonSituations":"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.","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"],"exampleFix":"// before\nawait createCustomerAccountWorkflow(container).run({\n  input: { customerData: { email } }, // no authIdentityId\n})\n\n// after\nawait createCustomerAccountWorkflow(container).run({\n  input: { customerData: { email }, authIdentityId },\n})","handlingStrategy":"validation","validationCode":"const [existing] = await customerService.listCustomers({ email })\nif (existing && !existing.has_account && !authIdentityId) {\n  // reuse/upgrade the existing guest instead of creating another\n}","typeGuard":null,"tryCatchPattern":"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 }","preventionTips":["Always register through an auth provider so authIdentityId is present","Reuse existing guest customer records for the same email"],"tags":["customer","guest","duplicate","signup"],"backgroundTag":"duplicate-guest-email","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}