Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export of content type on save fails when created in code and AllowedContentTypes is set to null #653

Closed
Luuk1983 opened this issue Jun 21, 2024 · 1 comment

Comments

@Luuk1983
Copy link

Luuk1983 commented Jun 21, 2024

Describe the bug
When creating a content type in code and setting the AllowedContentTypes property of the ContentType object to null, uSync will throw an error when saving this content type.

System.ArgumentNullException: Value cannot be null. (Parameter 'source')
   at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Linq.OrderedEnumerable`2..ctor(IEnumerable`1 source, Func`2 keySelector, IComparer`1 comparer, Boolean descending, OrderedEnumerable`1 parent)
   at System.Linq.Enumerable.OrderBy[TSource,TKey](IEnumerable`1 source, Func`2 keySelector)
   at uSync.Core.Serialization.Serializers.ContentTypeBaseSerializer`1.SerializeStructure(TObject item)
   at uSync.Core.Serialization.Serializers.ContentTypeSerializer.SerializeCore(IContentType item, SyncSerializerOptions options)
   at uSync.Core.Serialization.SyncSerializerRoot`1.Serialize(TObject item, SyncSerializerOptions options)
   at uSync.BackOffice.SyncHandlers.SyncHandlerRoot`2.SerializeItem(TObject item, SyncSerializerOptions options)
   at uSync.BackOffice.SyncHandlers.SyncHandlerRoot`2.Export_DoExport(TObject item, String filename, String[] folders, HandlerSettings config)
   at uSync.BackOffice.SyncHandlers.SyncHandlerRoot`2.Export(TObject item, String[] folders, HandlerSettings config)
   at uSync.BackOffice.SyncHandlers.SyncHandlerRoot`2.Handle(SavedNotification`1 notification)

image

To Reproduce
Steps to reproduce the behavior:
Create these two document types in code. It doesn't matter where; in a razor view, in a controller or in a composition:

var result = new ContentType(stringHelper, -1)
{
	Alias = "WorkingComposition",
	Description = "This composition works",
	Icon = "icon-home",
	Name = "Working composition",
};

contentTypeService.Save(result);

var result2 = new ContentType(stringHelper, -1)
{
	Alias = "NonWorkingComposition",
	Description = "This composition doesn't work",
	Icon = "icon-home color-red",
	Name = "Not working composition",
	AllowedContentTypes = null
};

contentTypeService.Save(result2);

When running this code, uSync will create the working composition file, but not the one where the AlloweedContentTypes are set to null:
image

Expected behavior
Because AllowedContentTypes is nullable I full expect it to be able to be set to null.

About your Site (please complete the following information):

  • Umbraco Version: 13.3.2
  • uSync Version: 13.2.3
@KevinJump
Copy link
Owner

Fixed in uSync 13.2.4 : https://github.com/KevinJump/uSync/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants