modelsbuilder/ModelsBuilder.Original

UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: NullReferenceException

Opened this issue · 1 comments

Hi all,

We've encountered a problem with one of our repos wherein the Modelbuilder custom tool is no longer working and throws an error within which the exception message states 'Object reference not set to an instance of an object'. It seems to be the same as the closed issue encountered here: #160 (was unsure whether to post in a closed issue or open a new one; apologies if the former is preferred).

We have <add key="Umbraco.ModelsBuilder.LanguageVersion" value="CSharp6" />` within our web.config from prior to this bug (as per one user's recommendation on the #160 issue) and our Umbraco version is 7.13.1. Any information on things to try or what the possible underlying cause could be would be appreciated.

This is the full output for the error:
UmbracoModelsBuilder: Starting v8.0.5 04/10/2021 11:27:07. UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError) {"Message":"An error has occurred.","ExceptionMessage":"Exception while creating a value.","ExceptionType":"System.Exception","StackTrace":" at Umbraco.Core.Cache.HttpRuntimeCacheProvider.GetCacheItem(String cacheKey, Func1 getCacheItem, Nullable1 timeout, Boolean isSliding, CacheItemPriority priority, CacheItemRemovedCallback removedCallback, CacheDependency dependency)\r\n at Umbraco.Core.Cache.HttpRuntimeCacheProvider.GetCacheItem(String cacheKey, Func1 getCacheItem)\r\n
at Umbraco.Core.Cache.DeepCloneRuntimeCacheProvider.GetCacheItem(String cacheKey, Func1 getCacheItem)\r\n at Archetype.Extensions.ArchetypeHelper.GetArchetypePreValueFromDataTypeId(Int32 dataTypeId)\r\n at Archetype.PropertyConverters.ArchetypeValueConverter.IsConverter(PublishedPropertyType propertyType)\r\n at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()\r\n
at System.Linq.Buffer1..ctor(IEnumerable1 source)\r\n
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)\r\n at Umbraco.Core.Models.PublishedContent.PublishedPropertyType.InitializeConverters()\r\n at Umbraco.Core.Models.PublishedContent.PublishedContentType.<.ctor>b__3_0(PropertyType x)\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()\r\n
at System.Linq.Buffer1..ctor(IEnumerable1 source)\r\n
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)\r\n at Umbraco.Core.Models.PublishedContent.PublishedContentType..ctor(IContentTypeComposition contentType)\r\n at Umbraco.Core.Models.PublishedContent.PublishedContentType.CreatePublishedContentType(PublishedItemType itemType, String alias)\r\n at Umbraco.Core.Cache.CacheProviderExtensions.<>c__DisplayClass5_01.b__0()\r\n
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)\r\n
at Umbraco.Core.Cache.CacheProviderExtensions.GetCacheItem[T](ICacheProvider provider, String cacheKey, Func1 getCacheItem)\r\n at Umbraco.Core.Models.PublishedContent.PublishedContentType.Get(PublishedItemType itemType, String alias)\r\n at Umbraco.ModelsBuilder.Umbraco.Application.GetTypes(PublishedItemType itemType, IContentTypeBase[] contentTypes) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Umbraco\\Application.cs:line 169\r\n at Umbraco.ModelsBuilder.Umbraco.Application.GetAllTypes() in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Umbraco\\Application.cs:line 51\r\n at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(String modelsNamespace, IDictionary2 files) in D:\d\Zbu ModelsBuilder-7\Umbraco.ModelsBuilder\Api\ApiHelper.cs:line 13\r\n
at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in D:\d\Zbu ModelsBuilder-7\Umbraco.ModelsBuilder.Api\ModelsBuilderApiController.cs:line 65\r\n
at lambda_method(Closure , Object , Object[] )\r\n
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at Archetype.Extensions.ArchetypeHelper.RetrieveAdditionalProperties(ArchetypePreValue& preValue)\r\n at Archetype.Extensions.ArchetypeHelper.<>c__DisplayClass6.<GetArchetypePreValueFromDataTypeId>b__5()\r\n at Umbraco.Core.Cache.DictionaryCacheProviderBase.<>c__DisplayClass10_0.<GetSafeLazy>b__0()"}} UmbracoModelsBuilder: at Umbraco.ModelsBuilder.Api.ApiClient.EnsureSuccess(HttpResponseMessage result) at Umbraco.ModelsBuilder.Api.ApiClient.GetModels(Dictionary2 ourFiles, String modelsNamespace)
at Umbraco.ModelsBuilder.CustomTool.CustomTool.UmbracoModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)`

( As this issue is quite old - I'll create a new linked issue.. #259 )

I have the same issue - Umbraco 8.13.1 - added the web.config line etc.
If we do anything in the backoffice with doctypes etc, We get stackoverflow after the old generated models has been deleted, and before the new is generated.
After this the site will not start - Only solution to get the site restarted is to undo the deletion of the models (GIT undo changes).

Actual exception is in System.Collections.Generic.Dictionary.FindEntry() where key is IListableContent.
image

image

I've checked for looping compositions - any other ideas?

Using VS2022Ent - 64bit - Version 17.8.5