XC 10 storefront user register issue

There is a chance your storefront user register feature not working correctly.

You will see the following error from the page and exception detail in log:

Error: An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.
24876 09:26:17 ERROR Index was outside the bounds of the array.
Exception: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Source: Sitecore.Commerce.Engine.Connect
at Sitecore.Commerce.Engine.Connect.Pipelines.Customers.CreateUser.Process(ServicePipelineArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Commerce.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
at Sitecore.Commerce.Services.ServiceProvider.RunPipeline[TRequest,TResult](String pipelineName, TRequest request)
at Sitecore.Commerce.XA.Foundation.Connect.Managers.AccountManager.RegisterUser(IStorefrontContext storefrontContext, String userName, String password, String email, StringPropertyCollection propertyBag)

First you need to check is your Sitecore domain setup correctly in Sitecore and Commerce Engine.

Second you need to check the email address you used for test is not start with your Sitecore domain.

After you submit the form, Sitecore will format your email address with Sitecore domain in RegisterUserRepository class. The code is below:

If your username is start with Sitecore domain then it will consider your username already formatted which will cause above error in the following code.