umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.42k stars 2.67k forks source link

V8: ModelsBuilder fails too offen #5386

Closed nielslyngsoe closed 4 years ago

nielslyngsoe commented 5 years ago

Hi Stephan

I'm reporting this without any specifics, but because I think we need to look into this, my impression is that I'm not the only one experiencing this.

When testing and working with Umbraco I too offen see errors regarding ModelBuilder. I dont know what is happening or why, but my point is that for the small things I change in the StarterKit I should not be seeing issues like this — It make me think that the platform is very fragile, therefor I think we should investigate, why these are happening, can we avoid it from happening, if not, can we provide better error messages that will help people.

Thanks

Typical errors:

image

Stacktrace at System.Web.Compilation.BuildManager.PostProcessFoundBuildResult(BuildResult result, Boolean keyFromVPP, VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at Umbraco.Web.Mvc.ProfilingView.Render(ViewContext viewContext, TextWriter writer) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Mvc\ProfilingView.cs:line 25 at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Mvc\ControllerExtensions.cs:line 79 at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\PartialViewMacroEngine.cs:line 98 at Umbraco.Web.Macros.MacroRenderer.ExecutePartialView(MacroModel macro, IPublishedContent content) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 358 at Umbraco.Web.Macros.MacroRenderer.<>cDisplayClass17_0.b__0() in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 334 at Umbraco.Web.Macros.MacroRenderer.ExecuteProfileMacroWithErrorWrapper(MacroModel macro, String msgIn, Func1 getMacroContent, Func1 msgErr) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 305 at Umbraco.Web.Macros.MacroRenderer.ExecuteMacroWithErrorWrapper(MacroModel macro, String msgIn, String msgOut, Func1 getMacroContent, Func1 msgErr) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 264 at Umbraco.Web.Macros.MacroRenderer.ExecuteMacroOfType(MacroModel model, IPublishedContent content) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 331 at Umbraco.Web.Macros.MacroRenderer.Render(MacroModel macro, IPublishedContent content, IDictionary pageElements) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 237 at Umbraco.Web.Macros.MacroRenderer.Render(String macroAlias, IPublishedContent content, IDictionary2 macroParams) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 209 at Umbraco.Web.UmbracoComponentRenderer.RenderMacro(String alias, IDictionary2 parameters, IPublishedContent content) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\UmbracoComponentRenderer.cs:line 120 at Umbraco.Web.UmbracoComponentRenderer.RenderMacro(Int32 contentId, String alias, IDictionary2 parameters) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\UmbracoComponentRenderer.cs:line 100 at Umbraco.Web.Editors.MacroRenderingController.GetMacroResultAsHtml(String macroAlias, Int32 pageId, IDictionary2 macroParams) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Editors\MacroRenderingController.cs:line 137 at Umbraco.Web.Editors.MacroRenderingController.GetMacroResultAsHtmlForEditor(MacroParameterModel model) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Editors\MacroRenderingController.cs:line 91 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>cDisplayClass6_2.b2(Object instance, Object[] methodParameters) at Umbraco.Web.Macros.MacroRenderer.ExecuteProfileMacroWithErrorWrapper(MacroModel macro, String msgIn, Func1 getMacroContent, Func1 msgErr) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 305 at Umbraco.Web.Macros.MacroRenderer.ExecuteMacroWithErrorWrapper(MacroModel macro, String msgIn, String msgOut, Func1 getMacroContent, Func1 msgErr) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 264 at Umbraco.Web.Macros.MacroRenderer.ExecuteMacroOfType(MacroModel model, IPublishedContent content) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 331 at Umbraco.Web.Macros.MacroRenderer.Render(MacroModel macro, IPublishedContent content, IDictionary pageElements) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 237 at Umbraco.Web.Macros.MacroRenderer.Render(String macroAlias, IPublishedContent content, IDictionary2 macroParams) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Macros\MacroRenderer.cs:line 209 at Umbraco.Web.UmbracoComponentRenderer.RenderMacro(String alias, IDictionary2 parameters, IPublishedContent content) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\UmbracoComponentRenderer.cs:line 120 at Umbraco.Web.UmbracoComponentRenderer.RenderMacro(Int32 contentId, String alias, IDictionary2 parameters) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\UmbracoComponentRenderer.cs:line 100 at Umbraco.Web.Editors.MacroRenderingController.GetMacroResultAsHtml(String macroAlias, Int32 pageId, IDictionary2 macroParams) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Editors\MacroRenderingController.cs:line 137 at Umbraco.Web.Editors.MacroRenderingController.GetMacroResultAsHtmlForEditor(MacroParameterModel model) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Web\Editors\MacroRenderingController.cs:line 91 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.b2(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.d1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d5.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Filters.ActionFilterAttribute.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.d5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.d3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ExceptionFilterResult.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Web.Http.Controllers.ExceptionFilterResult.d6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.d15.MoveNext()

image

Last generation failed with the following error: Failed to build PureLive models. Could not find a datatype with identifier 0. Parameter name: id

at Umbraco.Core.Models.PublishedContent.PublishedContentTypeFactory.GetDataType(Int32 id) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Core\Models\PublishedContent\PublishedContentTypeFactory.cs:line 82 at Umbraco.Core.Models.PublishedContent.PublishedPropertyType..ctor(String propertyTypeAlias, Int32 dataTypeId, Boolean isUserProperty, ContentVariation variations, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Core\Models\PublishedContent\PublishedPropertyType.cs:line 71 at Umbraco.Core.Models.PublishedContent.PublishedPropertyType..ctor(PublishedContentType contentType, PropertyType propertyType, PropertyValueConverterCollection propertyValueConverters, IPublishedModelFactory publishedModelFactory, IPublishedContentTypeFactory factory) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Core\Models\PublishedContent\PublishedPropertyType.cs:line 36 at Umbraco.Core.Models.PublishedContent.PublishedContentTypeFactory.CreatePropertyType(PublishedContentType contentType, PropertyType propertyType) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Core\Models\PublishedContent\PublishedContentTypeFactory.cs:line 49 at Umbraco.Core.Models.PublishedContent.PublishedContentType.<>c__DisplayClass2_0.<.ctor>b__0(PropertyType x) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Core\Models\PublishedContent\PublishedContentType.cs:line 26 at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Umbraco.Core.Models.PublishedContent.PublishedContentType..ctor(IContentTypeComposition contentType, IPublishedContentTypeFactory factory) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Core\Models\PublishedContent\PublishedContentType.cs:line 25 at Umbraco.Core.Models.PublishedContent.PublishedContentTypeFactory.CreateContentType(IContentTypeComposition contentType) in C:\Projects\Umbraco\Umbraco-CMS-v8\src\Umbraco.Core\Models\PublishedContent\PublishedContentTypeFactory.cs:line 31 at Umbraco.ModelsBuilder.Umbraco.UmbracoServices.GetTypes(PublishedItemType itemType, IContentTypeComposition[] contentTypes) in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\UmbracoServices.cs:line 125 at Umbraco.ModelsBuilder.Umbraco.UmbracoServices.GetAllTypes() in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\UmbracoServices.cs:line 41 at Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory.GetModelsAssembly(Boolean forceRebuild) in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\PureLiveModelFactory.cs:line 336 at Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory.EnsureModels() in D:\d\Zbu ModelsBuilder\src\Umbraco.ModelsBuilder\Umbraco\PureLiveModelFactory.cs:line 283

marcemarc commented 5 years ago

Hi @nielslyngsoe it would be great to get some context to the small changes you have made...

ModelsBuilder is the bit that takes what the Umbraco Services provide, and generates a model to use in a View, so if there is a problem anywhere with your Umbraco site... it will be ModelsBuilder that throws the error, and is the bearer of the bad news ;-( - that doesn't necessarily mean that ModelsBuilder is the cause of the issue! and making Modelsbuilder mask problems in the services may not be the best use of energy, as those underlying issues will not necessarily be resolved.

In the stack trace above it appears that the there is a property on a document type/composition that has a PropertyType which does not have an associated DataType. If this is the case, it is better to try to understand the scenario for how this has occurred, rather than have Modelsbuilder 'not throw an error' if it can't find a DataType...

So having exact steps to reproduce is really super helpful as it enables us to find a fix for the problem when it occurs, not further down the chain when the consequences are rendered.

eg this is a fresh install of the starter kit or , I just deleted a DataType or I,was working on a new property editor and... etc etc

something strange has occurred for sure!

If we added some logging of the alias here:

https://github.com/umbraco/Umbraco-CMS/blob/853087a75044b814df458457dc9a1f778cc89749/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs#L66

would help troubleshoot which property editor has the issue.

greystate commented 4 years ago

I'm seeing this very often lately.

I'm using v8 (8.5.4 8.5.3, ed.) on Umbraco Cloud and the "default" Models Builder mode (PureLive I guess?)

Shazwazza commented 4 years ago

Nobody has mentioned exactly what v8 version they are using, there are lots of fixes relating to MB in later v8 versions, please upgrade to vlatest and see how that goes.

greystate commented 4 years ago

@Shazwazza Oops - sorry; I've updated my comment with a version number - very latest one I guess, as it was a brand new Umbraco Cloud project...

greystate commented 4 years ago

@Shazwazza Double-sorry - turns out Cloud had just upgraded the project before I looked :D Will test on this (now) brand newest version.

nielslyngsoe commented 4 years ago

With the recent change of the ModelsBuilder this issue is not relevant anymore.