U4-3279 - YSOD when there is no content / content types created - PublishedContent issue

Created by Shannon Deminick 31 Oct 2013, 00:43:11 Updated by Shannon Deminick 31 Oct 2013, 22:58:43

Easy to replicate, just have an install of umbraco with no content or content types and then go to /

You'll get a YSOD:

Server Error in '/' Application.

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

[No relevant source lines]

Source File: PublishedContentType.cs Line: 28

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] Umbraco.Core.Models.PublishedContent.PublishedContentType..ctor(IContentTypeComposition contentType) in PublishedContentType.cs:28 Umbraco.Core.Models.PublishedContent.PublishedContentType.CreatePublishedContentType(PublishedItemType itemType, String alias) in PublishedContentType.cs:148 Umbraco.Core.Models.PublishedContent.<>c__DisplayClassc.b__b() in PublishedContentType.cs:134 Umbraco.Core.Cache.<>c__DisplayClass161.<GetCacheItem>b__15(String key) in StaticCacheProvider.cs:77 System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) +72 Umbraco.Core.Cache.StaticCacheProvider.GetCacheItem(String cacheKey, Func1 getCacheItem) in StaticCacheProvider.cs:77 Umbraco.Core.CacheHelper.GetStaticCacheItem(String cacheKey, Func1 getCacheItem) in CacheHelper.cs:198 Umbraco.Core.Models.PublishedContent.PublishedContentType.Get(PublishedItemType itemType, String alias) in PublishedContentType.cs:133 Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Initialize() in XmlPublishedContent.cs:407 Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent..ctor(XmlNode xmlNode, Boolean isPreviewing) in XmlPublishedContent.cs:34 Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.ConvertToDocument(XmlNode xmlNode, Boolean isPreviewing) in PublishedContentCache.cs:241 Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetSingleByXPath(UmbracoContext umbracoContext, Boolean preview, String xpath, XPathVariable[] vars) in PublishedContentCache.cs:275 Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.DetermineIdByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Boolean hideTopLevelNode) in PublishedContentCache.cs:101 Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Nullable1 hideTopLevelNode) in PublishedContentCache.cs:52 Umbraco.Web.PublishedCache.ContextualPublishedContentCache.GetByRoute(Boolean preview, String route, Nullable1 hideTopLevelNode) in ContextualPublishedContentCache.cs:48 Umbraco.Web.PublishedCache.ContextualPublishedContentCache.GetByRoute(String route, Nullable1 hideTopLevelNode) in ContextualPublishedContentCache.cs:35 Umbraco.Web.Routing.ContentFinderByNiceUrl.FindContent(PublishedContentRequest docreq, String route) in ContentFinderByNiceUrl.cs:42 Umbraco.Web.Routing.ContentFinderByNiceUrl.TryFindContent(PublishedContentRequest docRequest) in ContentFinderByNiceUrl.cs:28 Umbraco.Web.Routing.PublishedContentRequestEngine.b__2a(IContentFinder finder) in PublishedContentRequestEngine.cs:345 System.Linq.Enumerable.Any(IEnumerable1 source, Func2 predicate) +146 Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContent() in PublishedContentRequestEngine.cs:345 Umbraco.Web.Routing.PublishedContentRequestEngine.FindPublishedContentAndTemplate() in PublishedContentRequestEngine.cs:303 Umbraco.Web.Routing.PublishedContentRequestEngine.PrepareRequest() in PublishedContentRequestEngine.cs:72 Umbraco.Web.Routing.PublishedContentRequest.Prepare() in PublishedContentRequest.cs:61 Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext) in UmbracoModule.cs:115 Umbraco.Web.UmbracoModule.b__7(Object sender, EventArgs e) in UmbracoModule.cs:527 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

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

Comments

Shannon Deminick 31 Oct 2013, 00:44:43

Actually it doesn't matter about no content types, this just happens when there's no content.


Stephan 31 Oct 2013, 08:11:59

If you have no content then why oh why is it trying to convert a content to an IPublishedContent -- and failing, because you have no content types. Granted, the exception should be more explicit -- going to work on that one today. But.... it looks like Umbraco actually ''did'' find some content.

Happened to me when a) you run your test website and create some content that goes to umbraco.config then b) you wipe the database and start again, but don't remove umbraco.config so c) umbraco.config is still there and not empty => umbraco thinks you have content.


Stephan 31 Oct 2013, 17:30:50

I am pretty sure that's the cause of the issue. Have pushed commit 7677193 in 6.2 that brings a better exception message, such as "ContentTypeService failed to find a content type with alias 'whatever'". Now you have to figure out why we're looking for such a content type in the first place, if it does not exist -- usually because of a rogue umbraco.config.


Shannon Deminick 31 Oct 2013, 22:58:39

Ahh yup, def think it's a rogue umbraco.config! Will mark this as fixed, thanks for looking into that!


Priority: Major

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.0, 6.2.0

Due in version: 7.0.0, 6.2.0

Sprint:

Story Points:

Cycle: