U4-9658 - Handle exception when the umbraco.config file is out of date and throws when an incorrect document type is found

Created by Shannon Deminick 22 Mar 2017, 03:11:58 Updated by Shannon Deminick 23 Mar 2017, 01:15:58

Tags: Unscheduled

Subtask of: U4-9609

The exception is like:

ContentTypeService failed to find a content type with alias "asdfasdf".

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.InvalidOperationException: ContentTypeService failed to find a content type with alias "asdfasdf".

Source Error: 


Line 183:                    itemType.ToString().ToLower(), alias));
Line 184:
Line 185:            return new PublishedContentType(contentType);
Line 186:        }
Line 187:

Source File: X:\Projects\Umbraco\Umbraco_7.5\src\Umbraco.Core\Models\PublishedContent\PublishedContentType.cs    Line: 185 

And it's because the umbraco.config file contains data for content types that doesn't exist. It's easy to test locally by shutting down your site and adding a content node with a content type name that doesn't exist.

We should handle this error much more elegantly.

Comments

Stephan 22 Mar 2017, 13:03:42

PR: https://github.com/umbraco/Umbraco-CMS/pull/1814

whenever the content cache tries to get a content type that does not exist, we throw an explicit exception and reload the entire content cache from database (thus refreshing umbraco.config). next time (next request), the issue is gone (self-fixed).

review: replace umbraco.config with a totally different one coming from another site, and restart. you should see the exception once, and then umbraco.config should be healed.

as for the original exception in the description (about a type not existing in a namespace) it indicates that models are not available. however, the same exception could be thrown for any other missing type in the view, so we cannot really rebuild models each time it's thrown. tempted to do nothing here, ''but'' next time it happens, would love to get a capture of the models error file.

so, moving the entire issue to revie.


Shannon Deminick 23 Mar 2017, 01:15:54

@zpqrtbnk I've updated the error desc for this task so it's not confusing to end users, I've also fixed up the exception handling in rev: e7a540e717124187c68e6c0deb52aaafa5479109 (as per my commments on the PR)


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.5.12

Sprint: Sprint 55

Story Points:

Cycle: