U4-3187 - testing a DictionaryItem parent thows an exception

Created by Kevin Jump 17 Oct 2013, 14:17:07 Updated by Shannon Deminick 21 Jun 2017, 07:58:15

testing for the '''Parent''' value of a DictionaryItem throws an exception if Parent is null.


if ( item.Parent != null ) Throws the exception "ArgumentException: Top most dictionary items doesn't have a parent"

The DictionaryItem class, throws this exception from the property value



/// Returns the parent. /// public DictionaryItem Parent { get { EnsureCache(); if (_parent == null) { var p = DictionaryItems.Values.SingleOrDefault(x => x.UniqueId == this.ParentId);

		if (p == null)
			throw new ArgumentException("Top most dictionary items doesn't have a parent");
			_parent = p;

        return _parent;


idealy testing a property for null shouldn't throw an exception.

I don't know if this is an knock on effect because '''IsTopMost()''' doesn't seem to consistently return the correct result.

my code is below - during testing it looks like '''IsTopMost()''' returns false, but parent is null in some cases.

private static Dictionary.DictionaryItem GetTop(Dictionary.DictionaryItem item) { if (!item.IsTopMostItem()) { LogHelper.Debug("is Top Most [{0}]", ()=> item.IsTopMostItem()); if (item.Parent != null) { LogHelper.Debug("parent [{0}]", () => item.Parent.key); return GetTop(item.Parent); } }

return item; 



Shannon Deminick 21 Jun 2017, 07:58:15

Closing issue due to inactivity - see blog post for details https://umbraco.com/blog/issue-tracker-cleanup/

Priority: Normal

Type: Bug

State: Closed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 4.11.10, 6.1.6

Due in version:


Story Points: