Copied to clipboard

Flag this post as spam?

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


  • M 39 posts 261 karma points
    Jun 21, 2022 @ 11:47
    M
    0

    uSync mixing up group and tab keys

    Hi Kevin,

    We're trying to use uSync to standardise settings on some new V9.5.2 sites. Some of the document types were created separately on 2 sites before we found uSync, so now we're merging the uSync config files and importing. This has worked as expected apart from 1 file which throws the error:

    An item with the same key has already been added. Key: settings
       at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
       at System.Collections.ObjectModel.KeyedCollection`2.ChangeItemKey(TItem item, TKey newKey)
       at Umbraco.Cms.Core.Models.PropertyGroup.set_Alias(String value)
       at uSync.Core.Serialization.Serializers.ContentTypeBaseSerializer`1.DeserializeTabs(TObject item, XElement node)
       at uSync.Core.Serialization.Serializers.ContentTypeSerializer.DeserializeCore(XElement node, SyncSerializerOptions options)
       at uSync.Core.Serialization.SyncSerializerRoot`1.Deserialize(XElement node, SyncSerializerOptions options)
       at uSync.BackOffice.SyncHandlers.SyncHandlerRoot`2.ImportElement(XElement node, String filename, HandlerSettings settings, uSyncImportOptions options)
    

    The issue seems to be it is trying to replace a key twice.

    Old .config:

    <Tabs>
      <Tab>
          <Key>a4bf4506-f368-4f9b-8788-6e0f00230433</Key>
          <Caption>Settings</Caption>
          <Alias>settings/settings</Alias>
          <Type>Group</Type>
          <SortOrder>0</SortOrder>
      </Tab>
      <Tab>
          <Key>2b701c9b-1b5e-4cb0-9827-aac6163f4892</Key>
          <Caption>Settings</Caption>
          <Alias>settings</Alias>
          <Type>Tab</Type>
          <SortOrder>0</SortOrder>
      </Tab></Tabs>
    

    New .config:

    <Tabs>
      <Tab>
          <Key>a4bf4506-f368-4f9b-8788-6e0f00230433</Key>
          <Caption>Design settings</Caption>
          <Alias>settings/designSettings</Alias>
          <Type>Group</Type>
          <SortOrder>0</SortOrder>
      </Tab>
      <Tab>
          <Key>4691bdce-7d5a-4cf4-ae01-c54f893c86de</Key>
          <Caption>Settings</Caption>
          <Alias>settings</Alias>
          <Type>Tab</Type>
          <SortOrder>0</SortOrder>
      </Tab></Tabs>
    

    Report: enter image description here

    As you can see from the report it's wanting to change both the keys to be the same and change the group to a tab. We tried changing the group name in case that was causing a conflict and changing the order in the .config, but still the same results. We even tried altering the config file to remove the group and just leave the tab. We have other doctypes setup in the same way, which have merged without issue. Any ideas?

  • Kevin Jump 2150 posts 13644 karma points MVP 6x c-trib
    Jun 21, 2022 @ 12:04
    Kevin Jump
    100

    Hi,

    Yeah if you ar emerging two sites its probibly because of the mixture of tabs and groups in the sites.

    internally inside umbraco you can't have a tab and a group have the same alias and key,

    Looking at your files i think you have somehow ended up with that. the first one .

     <Key>a4bf4506-f368-4f9b-8788-6e0f00230433</Key>
     <Caption>Settings</Caption>
     <Alias>settings/settings</Alias>
    

    is a clash with the second.

    <Key>a4bf4506-f368-4f9b-8788-6e0f00230433</Key>
    <Caption>Design settings</Caption>
    <Alias>settings/designSettings</Alias>
    

    I would try changing the key value on one of the files (e.g. change the end of the key 33 to 34 or something)

    that or try a full export from the source, really the key/alias pairs should always be unique so its a little odd they have ended up not being.

    Kevin

  • M 39 posts 261 karma points
    Jun 21, 2022 @ 13:35
    M
    0

    Thanks for the super fast reply; it pointed me in the right direction. There was another block doc type with a group with the same alias (settings). Changed both to something a bit more descriptive and hey presto!

    Thanks again

Please Sign in or register to post replies

Write your reply to:

Draft