Custom content providers returning incorrect data cause hard to understand exception

Found in

EPiServer.CMS.Core 7.5.394.2

Fixed in

EPiServer.CMS.Core 10.7.0

Created

Feb 28, 2017

Updated

Apr 07, 2017

Area

CMS Core

State

Closed, Fixed and tested


Description

A custom content provider can cause a KeyNotFoundException when content is returned that was not expected.

A better exception should be thrown, such as:
"Content provider X returned unexpected content link Y that was not in the requested list of content links"

[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary`2.get_Item(TKey key) +12347693
EPiServer.Core.ContentProvider.GetScatteredContents(IEnumerable`1 contentLinks, ILanguageSelector selector) +784
EPiServer.Core.ContentProvider.LoadBatched(IList`1 contentReferences, ILanguageSelector selector) +40
EPiServer.Core.ProviderPipelineImplementation.GetItems(ContentProvider provider, IList`1 contentLinks, LoaderOptions loaderOptions) +225
EPiServer.Core.DefaultContentLoader.GetChildren(ContentReference contentLink, LoaderOptions loaderOptions, Int32 startIndex, Int32 maxRows) +1668
EPiServer.Core.DefaultContentLoader.GetChildren(ContentReference contentLink, LoaderOptions loaderOptions) +67
EPiServer.Core.DefaultContentRepository.GetChildren(ContentReference contentLink, LoaderOptions loaderOptions) +66