U4-7892 - Sequence contains no matching element - packaging service

Created by Jon Humphrey 03 Feb 2016, 15:17:24 Updated by Shannon Deminick 11 Feb 2016, 15:41:27

While creating a starter kit for my client I've updated the standard Media Image Type to use the Umbraco.ImageCropper following @crumpled_jeavon's example [here |https://umbraco.com/follow-us/blog-archive/2014/5/30/developing-a-website-with-responsive-images-using-the-umbraco-v714-image-cropper/] and included the new data type in my package.

When trying to install the kit to a new 7.3.x instance, with the required Archetype 1.12.0, RJP MultiUrlPicker 1.3.1, and ImageProcessor v2.3.0 installed already, I received the following error:

Server Error in '/' Application.

Sequence contains no matching element

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.InvalidOperationException: Sequence contains no matching element

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: 


[InvalidOperationException: Sequence contains no matching element]
   System.Linq.Enumerable.First(IEnumerable`1 source, Func`2 predicate) +276
   Umbraco.Core.Services.PackagingService.SavePrevaluesFromXml(List`1 dataTypes, IEnumerable`1 dataTypeElements) +214
   Umbraco.Core.Services.PackagingService.ImportDataTypeDefinitions(XElement element, Int32 userId, Boolean raiseEvents) +1430
   umbraco.cms.businesslogic.packager.Installer.InstallBusinessLogic(Int32 packageId, String tempDir) +412
   umbraco.presentation.developer.packages.Installer.ProcessInstall(String currentStep) +328
   umbraco.presentation.developer.packages.Installer.Page_Load(Object sender, EventArgs e) +498
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   umbraco.BasePages.BasePage.OnLoad(EventArgs e) +14
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2952

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1038.0

this didn't happen before creating the new DataType and including it in the package?

The conflicting code is this DataType declaration in the package.xml:

    <DataType Name="General Cropper" Id="Umbraco.ImageCropper" Definition="1df9f033-e6d4-451f-b8d2-e0cbc50a836f" DatabaseType="Ntext">
      <PreValues>
        <PreValue Id="403" Value="[]" Alias="crops" SortOrder="0" />
      </PreValues>
    </DataType>

I'm happy to send you both the "broken" kit, as well as the "working" kit if this helps, but of course it's client work and will need to be kept to yourselves.

I've created a [pull request|https://github.com/umbraco/Umbraco-CMS/pull/1093] for the updated code, hopefully this will help anyone else who hits the same issue!

Thaks for everything with Umbraco, I couldn't be without it now!

Jon

Comments

Shannon Deminick 11 Feb 2016, 14:11:39

I've fixed up some null checks and some string null checks, for review: dccee93700d6123683921e83b2fbf00306ee0898


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted: Pull request

Affected versions:

Due in version: 7.4.0

Sprint: Sprint 8

Story Points:

Cycle: