Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marcin Zajkowski 112 posts 585 karma points MVP 6x c-trib
    Jun 03, 2019 @ 14:32
    Marcin Zajkowski
    0

    An item with the same key has already been added?

    After the uSync upgrade, we've cleaned up the structure of all the definitions and performed some change on one of the datatypes (prevalues).

    Umbraco 7.10.4 & uSync 4.0.10 + uSync.Core 6.0.11.

    It got correctly updated on staging and client-staging environment, but when we moved it to the further instance we've got a weird error with the stacktrace below:

    Unhandled controller exception occurred
    System.ArgumentException: An item with the same key has already been added.
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at Jumoo.uSync.Core.Serializers.DataTypeSerializer.DeserializeUpdatePreValues(IDataTypeDefinition item, XElement node)
       at Jumoo.uSync.Core.Serializers.DataTypeSerializer.DeserializeItem(XElement node, IDataTypeDefinition item)
       at Jumoo.uSync.Core.Serializers.DataTypeSerializer.DeserializeCore(XElement node)
       at Jumoo.uSync.Core.Serializers.DataTypeSyncBaseSerializer.DeSerialize(XElement node, Boolean forceUpdate)
       at Jumoo.uSync.Core.Serializers.DataTypeSyncBaseSerializer.Deserialize(XElement node, Boolean forceUpdate, Boolean onePass)
       at Jumoo.uSync.BackOffice.Handlers.DataTypeHandler.Import(String filePath, Boolean force)
       at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler`1.ImportFolder(String folder, Boolean force, Dictionary`2 updates)
       at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler`1.ImportFolder(String folder, Boolean force, Dictionary`2 updates)
       at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler`1.ImportFolder(String folder, Boolean force, Dictionary`2 updates)
       at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler`1.ImportFolder(String folder, Boolean force, Dictionary`2 updates)
       at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler`1.ImportAll(String folder, Boolean force)
       at Jumoo.uSync.BackOffice.uSyncBackOfficeContext.Import(IEnumerable`1 syncHandlers, String folder, Boolean checkConfig, Boolean force, String groupName)
       at Jumoo.uSync.BackOffice.uSyncBackOfficeContext.Import(String groupName, String folder, Boolean force)
       at Jumoo.uSync.BackOffice.uSyncBackOfficeContext.ImportAll(String folder, Boolean force)
       at Jumoo.uSync.BackOffice.Controllers.uSyncApiController.Import(Boolean force)
       at lambda_method(Closure , Object , Object[] )
       at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
       at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
       at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
    

    Is there anything what we need to move / add additionally to make it work? I've already enabled detailed logging and I can see it's happening during this flexible values parsing.. https://cl.ly/fad927c22bd5

    Help needed!

  • Kevin Jump 2311 posts 14696 karma points MVP 7x c-trib
    Jun 03, 2019 @ 14:47
    Kevin Jump
    0

    that's odd,

    it's probably this line failing : https://github.com/KevinJump/uSync/blob/5db81c13efbccc7459e1a782105fef02cd5c848d/Jumoo.uSync.Core/Serializers/DataTypeSerializer.cs#L283

    for lists (like a dropdown flexible, we try to match based on the name first (actual value) as this caters for sort orders, but then we add it to the dictionary by the alias, any chance to entries in the XML have the same alias?

    it might be an artefact of a rename of an existing value inside the xml, ? would be good if you can get the xml (config) you are trying to import and a copy of the xml that happens if you do an export of the target site ?

    this means we can then compare them and maybe workout what's going on.

    Kevin

  • Igor Delendik 1 post 71 karma points notactivated
    Feb 15, 2021 @ 13:18
    Igor Delendik
    0

    Hello,

    I've faced with the same issue when tried to remove some values from a dropdownMultiple.

    Umbraco version 7.15.4 assembly: 1.0.7381.11453 and (uSync.BackOffice 4.0.10.0) (uSync.Core 6.0.10.0)

    enter image description here enter image description here

    Thank you, Igor

  • Anderson Cox Cox 3 posts 73 karma points
    Feb 18, 2021 @ 04:13
    Anderson Cox Cox
    0

    Umbraco 7 After the Walgreenslistens uSync upgrade, we've cleaned up the structure of all the definitions and performed some change on one of the datatypes (prevalues).

    Umbraco 7.10.4 & uSync 4.0.10 + uSync.Core 6.0.11.

    It got correctly updated on staging and client-staging environment, but when we moved it to the further instance we've got a weird error with the stacktrace below:

    Unhandled controller exception occurred System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at Jumoo.uSync.Core.Serializers.DataTypeSerializer.DeserializeUpdatePreValues(IDataTypeDefinition item, XElement node) at Jumoo.uSync.Core.Serializers.DataTypeSerializer.DeserializeItem(XElement node, IDataTypeDefinition item) at Jumoo.uSync.Core.Serializers.DataTypeSerializer.DeserializeCore(XElement node) at Jumoo.uSync.Core.Serializers.DataTypeSyncBaseSerializer.DeSerialize(XElement node, Boolean forceUpdate) at Jumoo.uSync.Core.Serializers.DataTypeSyncBaseSerializer.Deserialize(XElement node, Boolean forceUpdate, Boolean onePass) at Jumoo.uSync.BackOffice.Handlers.DataTypeHandler.Import(String filePath, Boolean force) at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler1.ImportFolder(String folder, Boolean force, Dictionary2 updates) at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler1.ImportFolder(String folder, Boolean force, Dictionary2 updates) at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler1.ImportFolder(String folder, Boolean force, Dictionary2 updates) at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler1.ImportFolder(String folder, Boolean force, Dictionary2 updates) at Jumoo.uSync.BackOffice.Handlers.uSyncBaseHandler1.ImportAll(String folder, Boolean force) at Jumoo.uSync.BackOffice.uSyncBackOfficeContext.Import(IEnumerable1 syncHandlers, String folder, Boolean checkConfig, Boolean force, String groupName) at Jumoo.uSync.BackOffice.uSyncBackOfficeContext.Import(String groupName, String folder, Boolean force) at Jumoo.uSync.BackOffice.uSyncBackOfficeContext.ImportAll(String folder, Boolean force) at Jumoo.uSync.BackOffice.Controllers.uSyncApiController.Import(Boolean force) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.

    Help needed!

    Exception has been thrown by the target of an invocation. An item with the same key has already been added.

    WalgreensListens Survey

  • Chris Clancy 63 posts 132 karma points
    Apr 11, 2022 @ 10:50
    Chris Clancy
    0

    Using Umbraco 7.10.4 & uSync 4.0.10 + uSync.Core 6.0.11.

    The way around this for me is to ensure the auto import is turned off (set to false in the usyncBackOffice.config)

    <!-- run import at startup -->
    <Import>false</Import>
    

    Run your app and ensure set debug to info in log4net.config:

    <!-- Usync logger: Check Umb logs after running usync import/export -->
    <logger name="Jumoo.uSync">
       <level value="Debug" />
    </logger>
    

    With import turned off, the app should now run without seeing the error. Go to Developer section in the backoffice and run the Usync import.

    This should fail at the problem usync config file. Check the logs ( I use Diplo in the back office to make it easier) and hopefully the last item imported or listed during the import process will point you to the problem file(s). For me it was dropdown.flexible used for data types that had been created in an older usync vrsion. So I went into each of the data types using that type of property (searched Visual Studio to help find them) , added an extra property for that data type and saved to force an update to the necessary XML formatting required. I then closed the app, rebuilt and repeat the process until the backoffice import runs successfully. Then go in and remove any additional properties that you added and save out again.

    If there are new data types being imported and you haven't been able to update them - run the import and they should still be brought in, allowing you to rebuild the app and access them for updating.

    You can probably also edit them manually. The updated and working version looks like this:

      <DataType Name="Module Overlay" Key="21d07e8f-a2da-4fe3-9cba-1cbd4e9844c0" Id="Umbraco.DropDown.Flexible" DatabaseType="Nvarchar"   Folder="Custom">
        <PreValues>
          <PreValue SortOrder="1" Alias="0"><![CDATA[None]]></PreValue>
          <PreValue SortOrder="2" Alias="1"><![CDATA[Light]]></PreValue>
          <PreValue SortOrder="3" Alias="2"><![CDATA[Dark]]></PreValue>
          <PreValue SortOrder="4" Alias="multiple"><![CDATA[0]]></PreValue>
        </PreValues>
      </DataType>
    

    The non working version was like this:

    <?xml version="1.0" encoding="utf-8"?>
    <DataType Name="Module Overlay" Key="21d07e8f-a2da-4fe3-9cba-1cbd4e9844c0" Id="Umbraco.DropDown.Flexible" DatabaseType="Nvarchar" Folder="Custom">
      <PreValues>
        <PreValue Id="810" Value="None" Alias="0" />
        <PreValue Id="811" Value="Light" Alias="1" />
        <PreValue Id="812" Value="Dark" Alias="2" />
        <PreValue Id="813" Value="0" Alias="multiple" />
      </PreValues>
    </DataType>
    

    I can now set my import to true for startup and not get the errors any more. So as was stated earlier, it is most likely a dropdown.flexible issue and the XML formatting/data of the config file which the import does not like.

Please Sign in or register to post replies

Write your reply to:

Draft