U4-1300 - Bug in Umbraco.TypedContent when passed an ID that not longer exists or is in recycle bin

Created by Matt Brailsford 07 Dec 2012, 14:27:09 Updated by Shannon Deminick 24 Oct 2016, 07:44:51

Relates to: U4-2045

When calling TypedContent helper method and passing it an ID of an item in the recycle bin, a YSOD is thrown saying DynamicNULL can't be converted to IPublishedContent. I check needs to be added to the private TypedDocumentById to ensure the return value from DocumentById is not DynamicNull, and if it is, return null.

I'm not sure if there should be another helper that maybe doesn't return null at all (ie, if it doesn't exist or is in the bin, don't return anything).


Matt Brailsford 07 Dec 2012, 14:28:54

PS I've classified this as major because currently there is no way round it. If the node is in the bin, it YSODs so it's not possible to capture in a nice way. You could do a try catch, but it would mean whatever you are rendering, the whole thing would not display.

Chris Evans 14 Dec 2012, 01:48:07

I can confirm this happens - when calling

var node = @Umbraco.TypedContent(id);

if the id doesn't match a node that exists, throws the exception:

"Cannot implicitly convert type 'Umbraco.Core.Dynamics.DynamicNull' to 'Umbraco.Core.Models.IPublishedContent'. An explicit conversion exists (are you missing a cast?)"

Would expect it to return a null so that can be checked to see if the node exists or not?

Tom Madden 10 Apr 2013, 14:30:43

I've just been bitten by this as well in 4.11.5 (not update to 4.11.6 quite yet). It would be good to see this fixed in the 4.11 branch. Should this not be marked as open, rather than fixed?

Dan Sørensen 24 Oct 2016, 07:42:23

I still got this in version 7.. it says it fixed ?

Shannon Deminick 24 Oct 2016, 07:44:51

@saadan if you have steps to replicate, please open a new issue - once issues are closed they cannot be re-opened.

Priority: Major

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Easy

Category: Architecture

Backwards Compatible: False

Fix Submitted:

Affected versions: 4.10.0, 4.11.0, 4.11.1

Due in version: 6.0.0


Story Points: