Copied to clipboard

Flag this post as spam?

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


  • Pavel Gurecki 55 posts 158 karma points
    Jun 26, 2014 @ 15:23
    Pavel Gurecki
    0

    Upgrading 6.2.1 to 7.1.4 - "Failed to retrieve data for data type" error for MNTP

    Hello,

    after upgrading my 6.2.1 installation to 7.1.4 I've get YSOD when trying to open Multi Node Tree Picker based datatype:

     

    Failed to retrieve data for data type id 1081


    The given key was not present in the dictionary.

    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.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. 

    Stack Trace: 

    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Umbraco.Web.PropertyEditors.MultiNodeTreePickerPropertyEditor.MultiNodePickerPreValueEditor.ConvertDbToEditor(IDictionary`2 defaultPreVals, PreValueCollection persistedPreVals)
       at Umbraco.Web.Models.Mapping.PreValueDisplayResolver.Convert(IDataTypeDefinition source)
       at AutoMapper.ValueResolver`2.Resolve(ResolutionResult source)
       at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
       at AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.MapPropertyValue(ResolutionContext context, IMappingEngineRunner mapper, Object mappedObject, PropertyMap propertyMap)

     

    When I try to create content item with property of MNTP type, I get similar YSOD:

     

    Failed to retrieve data for empty content item type Testdoctype


    The given key was not present in the dictionary.

    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.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. 

    Stack Trace: 

    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Umbraco.Web.PropertyEditors.MultiNodeTreePickerPropertyEditor.MultiNodePickerPreValueEditor.ConvertDbToEditor(IDictionary`2 defaultPreVals, PreValueCollection persistedPreVals)
       at Umbraco.Web.Models.Mapping.ContentPropertyDisplayConverter.ConvertCore(Property originalProp)
       at AutoMapper.MappingExpression`2.<>c__DisplayClass15.<ConvertUsing>b__14(ResolutionContext context)
       at AutoMapper.Mappers.TypeMapObjectMapperRegistry.CustomMapperStrategy.Map(ResolutionContext context, IMappingEngineRunner mapper)
       at AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext context, IMappingEngineRunner mapper)
       at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)

     

    Other datatypes are ok. Content cache and examine indexes were rebuilt. I think that something gone wrong when installer was updating legacy property editors to v7 ones. 

    This is the biggest show-stopper, as MNTP is critical for my projects. 

    Found related forum threads (thread1, thread2, thread3 ) but no solution. Any help would be appreciated.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 26, 2014 @ 16:26
    Jan Skovgaard
    0

    Hi Pavel

    What steps did you take in order to upgrade to v7?

    I don't think that anything special is done in order to convert the MNTP from 6 to 7...I could be wrong but it does not work the same between the two versions...Don't know if you've seen this information about going from 6 to 7? http://our.umbraco.org/documentation/Installation/Upgrading/v7-upgrade

    Perhaps it can help.

    /Jan

  • Pavel Gurecki 55 posts 158 karma points
    Jun 26, 2014 @ 17:30
    Pavel Gurecki
    1

    Hi Jan,

    thanks for quick reply.

    I have done a lot and I'll need to do even more to make this upgrade successful. It includes checking all breaking changes, plugins, datatypes, upgrade guides, etc. This deserves whole blog post :)

    For now I've managed to fix this issue working directly with DB. I guess the problem is in https://github.com/umbraco/Umbraco-CMS/blob/7.1.4/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs : 70, it tries to get prevalue by "maxNumber" alias, which does not exist -> YSOD. 

    Temporary solution would be to remove all prevalues of MNTP datatypes and adding "maxNumber" prevalue row to each of them in database. Biggest drawback of this is that your settings will be lost. I will share my SQL script for that later.

    Ideally, Umbraco install should detect upgrade from previous versions and transform old MNTP prevalues to new ones. I will create an issue for this later.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 26, 2014 @ 17:51
    Jan Skovgaard
    1

    Hi Pavel

    I think that making minor upgrades easier is something that has focus in the core team. However it's not something that is likely to happen anytime soon. But auto-upgrading between major versions I think is not possible to do in a reliable manner since a lot of stuff is going on under the hood.

    But minor upgrades on the same major version it could indeed be made easier / probably automated. But it takes time and staff, which the HQ is short of right now.

    I regards to your upgrade experiences it would be nice if you would actually document it in a blogpost or in the documentation section here on our :) If you would like to contribute to the documentation it's possible to do it here https://github.com/umbraco/Umbraco4Docs

    Happy upgrading!

    /Jan

  • Pavel Gurecki 55 posts 158 karma points
    Jun 26, 2014 @ 19:19
    Pavel Gurecki
    104

    Thanks Jan, will share my experience on upgrading sooner or later.

    In case if someone will have same issue with MNTP, here's the SQL script for fixing this. You will need to fill in your DB name. Be aware that this will remove all prevalues for specified datatypes. Application pool recycle will be needed afterwards.

    -- This script should be run after Umbraco install script
    
    USE DatabaseName-- specify database
    GO
    
    DECLARE @datatypeIds TABLE (id int);
    
    INSERT INTO @datatypeIds
    SELECT  nodeId 
    FROM    cmsDataType 
    WHERE   propertyEditorAlias = 'Umbraco.MultiNodeTreePicker'
    
    DELETE FROM cmsDataTypePreValues
    WHERE datatypeNodeId IN (SELECT id FROM @datatypeIds);
    
    INSERT INTO cmsDataTypePreValues
    SELECT
        [@datatypeIds].id,
        1,  
        1,
        'maxNumber'
    FROM
    @datatypeIds;
    
    SELECT     *
    FROM       cmsDataTypePreValues
    WHERE     datatypeNodeId IN (SELECT id FROM @datatypeIds)
    GO
    

     Also you can vote for issue on tracker: http://issues.umbraco.org/issue/U4-5154

     

  • Tom C 87 posts 222 karma points
    Jun 28, 2014 @ 18:20
    Tom C
    0

    Thanks .. very helpful! should be done automaticlaly in the upgrade process though!

  • Kevin Nolan 9 posts 60 karma points
    Aug 04, 2014 @ 02:30
    Kevin Nolan
    0

    Pavel - you're a legend! Thanks for posting that solution!

     

     

  • Simon Dingley 1470 posts 3427 karma points c-trib
    Oct 24, 2014 @ 10:55
    Simon Dingley
    0

    What I've done is used your script which was incredibly useful thanks, then I went into my development version and added back in all of the prevalues and saved the inserts to a script I can run in production when I do the final upgrade on live. Hopefully this is something that will get addressed in the near future.

  • ljcooper 21 posts 86 karma points
    Aug 30, 2017 @ 13:02
    ljcooper
    0

    Holy &#*@#@, you just saved me a bunch of work. Thanks for the script and thanks for posting it here!

Please Sign in or register to post replies

Write your reply to:

Draft