uSync has been throwing a YSOD when it's trying to sync media types that have inheritance.
Here is the error
Read MediaType failed System.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.ArgumentException: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at Umbraco.Core.Models.PropertyGroupCollection.InsertItem(Int32 index, PropertyGroup item)
at Umbraco.Core.Models.PropertyGroupCollection.Add(PropertyGroup item)
at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
at Umbraco.Core.Models.PropertyGroupCollection.Reset(IEnumerable`1 groups)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapGroupsAndProperties(Int32[] contentTypeIds, Database db, IDictionary`2& allPropertyTypeCollection, IDictionary`2& allPropertyGroupCollection)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapContentTypeChildren[TRepo](IContentTypeComposition[] contentTypes, Database db, TRepo contentTypeRepository, IDictionary`2 allParentContentTypeIds)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.GetMediaTypes[TRepo](Int32[] mediaTypeIds, Database db, TRepo contentTypeRepository)
at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.GetAll(TId[] ids)
at Umbraco.Core.Services.ContentTypeService.GetAllMediaTypes(Int32[] ids)
at Umbraco.Core.Services.ContentTypeService.ValidateLocked(IContentTypeComposition compositionContentType)
at Umbraco.Core.Services.ContentTypeService.Save(IMediaType mediaType, Int32 userId)
at umbraco.cms.businesslogic.media.MediaType.Save()
at jumps.umbraco.usync.MediaTypeHelper.Import(XmlNode n, Boolean ImportStructure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.ArgumentException: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at Umbraco.Core.Models.PropertyGroupCollection.InsertItem(Int32 index, PropertyGroup item)
at Umbraco.Core.Models.PropertyGroupCollection.Add(PropertyGroup item)
at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
at Umbraco.Core.Models.PropertyGroupCollection.Reset(IEnumerable`1 groups)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapGroupsAndProperties(Int32[] contentTypeIds, Database db, IDictionary`2& allPropertyTypeCollection, IDictionary`2& allPropertyGroupCollection)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapContentTypeChildren[TRepo](IContentTypeComposition[] contentTypes, Database db, TRepo contentTypeRepository, IDictionary`2 allParentContentTypeIds)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.GetMediaTypes[TRepo](Int32[] mediaTypeIds, Database db, TRepo contentTypeRepository)
at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.GetAll(TId[] ids)
at Umbraco.Core.Services.ContentTypeService.GetAllMediaTypes(Int32[] ids)
at Umbraco.Core.Services.ContentTypeService.ValidateLocked(IContentTypeComposition compositionContentType)
at Umbraco.Core.Services.ContentTypeService.Save(IMediaType mediaType, Int32 userId)
at umbraco.cms.businesslogic.media.MediaType.Save()
at jumps.umbraco.usync.MediaTypeHelper.Import(XmlNode n, Boolean ImportStructure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.SystemException: Read MediaType failed System.ArgumentException: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.ObjectModel.KeyedCollection`2.AddKey(TKey key, TItem item)
at Umbraco.Core.Models.PropertyGroupCollection.InsertItem(Int32 index, PropertyGroup item)
at Umbraco.Core.Models.PropertyGroupCollection.Add(PropertyGroup item)
at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
at Umbraco.Core.Models.PropertyGroupCollection.Reset(IEnumerable`1 groups)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapGroupsAndProperties(Int32[] contentTypeIds, Database db, IDictionary`2& allPropertyTypeCollection, IDictionary`2& allPropertyGroupCollection)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.MapContentTypeChildren[TRepo](IContentTypeComposition[] contentTypes, Database db, TRepo contentTypeRepository, IDictionary`2 allParentContentTypeIds)
at Umbraco.Core.Persistence.Repositories.ContentTypeBaseRepository`1.ContentTypeQueryMapper.GetMediaTypes[TRepo](Int32[] mediaTypeIds, Database db, TRepo contentTypeRepository)
at Umbraco.Core.Persistence.Repositories.RepositoryBase`2.GetAll(TId[] ids)
at Umbraco.Core.Services.ContentTypeService.GetAllMediaTypes(Int32[] ids)
at Umbraco.Core.Services.ContentTypeService.ValidateLocked(IContentTypeComposition compositionContentType)
at Umbraco.Core.Services.ContentTypeService.Save(IMediaType mediaType, Int32 userId)
at umbraco.cms.businesslogic.media.MediaType.Save()
at jumps.umbraco.usync.MediaTypeHelper.Import(XmlNode n, Boolean ImportStructure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)
at jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure)]
jumps.umbraco.usync.SyncMediaTypes.ReadFromDisk(String path, Boolean structure) +675
jumps.umbraco.usync.SyncMediaTypes.ReadAllFromDisk() +177
jumps.umbraco.usync.uSync.ReadAllFromDisk() +520
jumoo.usync.ui.uSyncUi.btnImport_Click(Object sender, EventArgs e) +30
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +155
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
I could send you the "MediaTypes" folder if that would be useful?
Ouch. Just ran into the same message. I used to be working OK on this site, but after upgrading to Umbraco vLatest in combination with uSync vLatest I'm receiving the same message.
I'm afraid not, we now delete the media types folder before executing a uSync import at the moment and have reverted to migrating media type changes manually
That's what I planned to do. I noticed there is a configuration switch in the uSyncSettings that excludes media from being synced.
Also found out that my issue probably not (only) related to uSync. I appears that in the upgrade process from v7.1.9 (I think) to v7.2.6 the doctype inheritance for media types was not handled properly. This may have caused the uSync error, but still investigating that...
I'm getting a little closer to the issue. Steps to reproduce:
Install a clean 7.2.6 umbraco install and setup uSync latest
Create child type for media and add some properties and select the File tab
for each of the properties (this is where things go wrong!)
Let uSync Export the document types (this goes well)
Let uSync Import the document types. This results in Read MediaType failed System.ArgumentException: An item with the same key has already been added.
Have a look at the media type definition on Settings, expand the File type. This results in ArgumentException: An item with the same key has already been added.
It appears that having the properties on the same tab as the master media type (probably especially the File tab), causes the issue.
Note that after this, the mediatypes are in a corrupted state. You cannot delete them, nor can you (re)import them, as the call to GetMediaTypes always results in ArgumentException: An item with the same key has already been added.
I don't know if this is a specific uSync error (the exported definitions looked ok) or related to the (latest) Umbraco release, but it makes nested mediatypes in combination with uSync useless :(
Sorry I missed the replies to this topic somewhere...
I've just had a (not to quick in the end) look again at the media service stuff in usync. for versions pre v2.x of uSync it's all a bit arcane the code, because it is using the old api's as the newer ones weren't 100% for media types pre umbraco v7.3.
After much faffing, I think the fix is to do the tabs in another way using some of the newer api for this bit of the sync. (inherited tabs are actually created both on the parent and child media type, and you have to make sure you add your items to the right tabs, and do it after you've done everything else, or it goes pop.)
There is an updated dll in github that contains this fix:
I haven't yet found the way to fix existing broken ones :( but removing the tab from parent (so putting existing properties into generic or something) might get you access to the child, but my install was quite messed up with loads of tests when i tried that!.
for v7.3+ (uSync 3.x) this works as the code uses the new API.
Worth noting in Umbraco 7.4 you can't have nested Media Types,
Trouble with Media Types that have inheritance
Hi Kevin,
uSync has been throwing a YSOD when it's trying to sync media types that have inheritance.
Here is the error
I could send you the "MediaTypes" folder if that would be useful?
Cheers,
Jeavon
Ouch. Just ran into the same message. I used to be working OK on this site, but after upgrading to Umbraco vLatest in combination with uSync vLatest I'm receiving the same message.
@Jeavon did you get around this?
I'm afraid not, we now delete the media types folder before executing a uSync import at the moment and have reverted to migrating media type changes manually
That's what I planned to do. I noticed there is a configuration switch in the uSyncSettings that excludes media from being synced.
Also found out that my issue probably not (only) related to uSync. I appears that in the upgrade process from v7.1.9 (I think) to v7.2.6 the doctype inheritance for media types was not handled properly. This may have caused the uSync error, but still investigating that...
Hi
The actual error looks to be buried deep in the core somewhere, but I think it relates to Umbraco importing the Tabs for the media type.
could you have a look at the media def.config files ? is It possible that the import file contains either two entries for a tab in the
or that the tab section of the child contains the tab name from a parent?
This shouldn't happen but if it has then it might be something that can be fixed at the export stage.
Kevin
Hey Kevin,
I don't see anything obvious...
Image - def.config
Then a child of Image MicrosoftTileIcon def.config
Thanks for looking into it
Jeavon
I'm getting a little closer to the issue. Steps to reproduce:
It appears that having the properties on the same tab as the master media type (probably especially the File tab), causes the issue.
Note that after this, the mediatypes are in a corrupted state. You cannot delete them, nor can you (re)import them, as the call to GetMediaTypes always results in ArgumentException: An item with the same key has already been added.
I don't know if this is a specific uSync error (the exported definitions looked ok) or related to the (latest) Umbraco release, but it makes nested mediatypes in combination with uSync useless :(
I ran into this problem just now. Is there a fix for it?
Regards Gijs
I haven't looked into this recently, but I believe that the latest, refactored version of uSync handles it better.
For me, the solution was to exclude mediaTypes from being synced, as once setup, these weren't changed anymore.
Thanks for your swift reply. How did you get the media-items out of the corrupted state they were in? Because that's the issue I'm facing now.
Restored the database ;-)
Or a deep dive into the database. That's what I did the first time in my development environment, but I can't remember the exact SQL statements.
Other than that, remove it and recreate it. But you will probably loose any existing media items :(
Hi
Sorry I missed the replies to this topic somewhere...
I've just had a (not to quick in the end) look again at the media service stuff in usync. for versions pre v2.x of uSync it's all a bit arcane the code, because it is using the old api's as the newer ones weren't 100% for media types pre umbraco v7.3.
After much faffing, I think the fix is to do the tabs in another way using some of the newer api for this bit of the sync. (inherited tabs are actually created both on the parent and child media type, and you have to make sure you add your items to the right tabs, and do it after you've done everything else, or it goes pop.)
There is an updated dll in github that contains this fix:
https://github.com/KevinJump/jumps.umbraco.usync/tree/v2.2-Umbraco-7/Package/uSync (you just need jumps.umbraco.usync.dll) once i've done some testing i will push out an updated package.
I haven't yet found the way to fix existing broken ones :( but removing the tab from parent (so putting existing properties into generic or something) might get you access to the child, but my install was quite messed up with loads of tests when i tried that!.
is working on a reply...