0

Working with sitecore 9.1.1 and SXA 1.8.1. The below error suddenly appeared on the CD URL.

Server Error in '/' Application. An item with the same key has already been added.

Below is the stack trace.

ERROR Failed to render rendering      
Exception: System.Web.HttpUnhandledException
    Message: An unhandled exception occurred.
    Source: Sitecore.Mvc
       at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)
       at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs 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.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
       at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)
       at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
       at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
       at System.Web.Mvc.Controller.ExecuteCore()
       at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
       at Sitecore.Mvc.Controllers.ControllerRunner.ExecuteController(Controller controller)
       at Sitecore.Mvc.Controllers.ControllerRunner.Execute(TextWriter writer)
       at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)
    
    Nested Exception
    
    Exception: System.ArgumentException
    Message: An item with the same key has already been added.
    Source: mscorlib
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add(KeyValuePair`2 keyValuePair)
       at Sitecore.XA.Foundation.Mvc.Wrappers.Parameters..ctor(RenderingParameters renderingParameters, IContext context)
       at Sitecore.XA.Foundation.Mvc.Wrappers.Rendering.get_Parameters()
       at Sitecore.XA.Foundation.Mvc.Repositories.Base.ModelRepository.get_HeadingTag()
       at Sitecore.XA.Foundation.Mvc.Repositories.Base.ModelRepository.FillBaseProperties(Object m)
       at Sitecore.XA.Feature.Context.Repositories.LanguageSelector.LanguageSelectorRepository.GetModel()
       at Sitecore.XA.Foundation.Mvc.Controllers.StandardController.Index()
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass24_0.<InvokeActionMethodWithFilters>b__0()
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
       at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)

Supposedly there was no recent changes made in the CM except for content entry in the content tree.

I'm not sure what "Item with same key" is the error referring to. While searching the internet, I found that this might be caused in forms if two fields are indeed having same key but I'm not using any forms here.

Any idea what might be other causes of this issue or how can I trace it?

0

Your errors occurs when fetching the rendering parameters of the LanguageSelector component. The "Item with the same key" refers to the fact that the a duplicate key is found when the code tries to read the parameters and place them in a Dictionary object.

As I never believe and "suddenly" and "supposedly" (editors never made a change when an error appears - that's the common answer) I would check your language selector component and verify the rendering parameters.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.