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.53k stars 2.7k forks source link

Exception thrown when upgrading from Umbraco 8.17.0 to 10.0.0 #14408

Open halfer53 opened 1 year ago

halfer53 commented 1 year ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10.0.0

Bug summary

I'm trying to upgrade the database from 8.17.0 to 10.0.0, then I got the following error. The same error can be reproduced using 10.5.1

System.InvalidOperationException: Set an alias before adding the property group. at Umbraco.Cms.Core.Models.PropertyGroupCollection.Add(PropertyGroup item) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeCommonRepository.MapGroupsAndProperties(IDictionary`2 contentTypes) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeCommonRepository.GetAllTypesInternal() at Umbraco.Extensions.AppCacheExtensions.<>c__DisplayClass0_0`1.b__0() at Umbraco.Cms.Core.Cache.SafeLazy.<>c__DisplayClass1_0.b__0() --- End of stack trace from previous location --- at Umbraco.Cms.Core.Cache.ObjectCacheAppCache.Get(String key, Func`1 factory, Nullable`1 timeout, Boolean isSliding, String[] dependentFiles) at Umbraco.Cms.Core.Cache.DeepCloneAppCache.Get(String key, Func`1 factory, Nullable`1 timeout, Boolean isSliding, String[] dependentFiles) at Umbraco.Extensions.AppCacheExtensions.GetCacheItem[T](IAppPolicyCache provider, String cacheKey, Func`1 getCacheItem, Nullable`1 timeout, Boolean isSliding, String[] dependentFiles) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeCommonRepository.GetAllTypes() at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeRepository.GetAllWithFullCachePolicy() at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeRepositoryBase`1.PerformGetAll(Int32[] ids) at Umbraco.Cms.Core.Cache.FullDataSetRepositoryCachePolicy`2.GetAllCached(Func`2 performGetAll) at Umbraco.Cms.Core.Cache.FullDataSetRepositoryCachePolicy`2.GetAll(TId[] ids, Func`2 performGetAll) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase`2.GetMany(TId[] ids) at Umbraco.Cms.Core.Services.ContentTypeServiceBase`2.GetAll(Int32[] ids) at Umbraco.Cms.Infrastructure.PublishedCache.DataSource.MsgPackContentNestedDataSerializerFactory.Create(ContentCacheDataSerializerEntityType types) at Umbraco.Cms.Infrastructure.PublishedCache.Persistence.NuCacheContentRepository.Rebuild(IReadOnlyCollection`1 contentTypeIds, IReadOnlyCollection`1 mediaTypeIds, IReadOnlyCollection`1 memberTypeIds) at Umbraco.Cms.Infrastructure.PublishedCache.Persistence.NuCacheContentService.Rebuild(IReadOnlyCollection`1 contentTypeIds, IReadOnlyCollection`1 mediaTypeIds, IReadOnlyCollection`1 memberTypeIds) at Umbraco.Cms.Infrastructure.PublishedCache.Persistence.NuCacheContentService.RebuildDatabaseCacheIfSerializerChanged() at Umbraco.Cms.Infrastructure.PublishedCache.NuCacheStartupHandler.Handle(UmbracoApplicationStartingNotification notification) at Umbraco.Cms.Core.Events.EventAggregator.PublishCore(IEnumerable`1 allHandlers, INotification notification) at Umbraco.Cms.Core.Events.NotificationHandlerWrapperImpl`1.Handle(INotification notification, ServiceFactory serviceFactory, Action`2 publish) at Umbraco.Cms.Core.Events.EventAggregator.PublishNotification(INotification notification) at Umbraco.Cms.Core.Events.EventAggregator.PublishAsync[TNotification](TNotification notification, CancellationToken cancellationToken) at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.StartAsync(CancellationToken cancellationToken, Boolean isRestarting) at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.RestartAsync() at Umbraco.Cms.Web.BackOffice.Install.InstallApiController.CompleteInstall() at lambda_method216(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Umbraco.Cms.Web.Common.Middleware.BasicAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<b__1>d.MoveNext() --- End of stack trace from previous location --- at Umbraco.Cms.Web.BackOffice.Middleware.BackOfficeExternalLoginProviderErrorMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry) at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 119 at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<b__1>d.MoveNext() --- End of stack trace from previous location --- at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<b__1>d.MoveNext() --- End of stack trace from previous location --- at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<b__1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) HEADERS ======= Accept: application/json, text/plain, */* Connection: keep-alive Host: localhost:3178 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.51 Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7 Content-Type: application/json;charset=UTF-8 Cookie: UMB_UPDCHK=1; Bucket=cEfgioe5QBKeQJ4tYnpGow; Varient=1; umb_installId=8e09e6c8-ba39-4ede-8458-195fd1e3cc2b; UMB_UCONTEXT_C=2023-06-19T10%3A04%3A02.7568504%2B00%3A00; UMB_UCONTEXT=<redacted> Origin: http://localhost:3178 Referer: http://localhost:3178/install?redir=true&url=http://localhost:3178/ Content-Length: 269 sec-ch-ua: "Not.A/Brand";v="8", "Chromium";v="114", "Microsoft Edge";v="114" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" Sec-Fetch-Site: same-origin Sec-Fetch-Mode: cors Sec-Fetch-Dest: empty

Specifics

Context: I'm upgrading an old umbraco project from 7. I removed and updated some of the data properties and managed to successfully upgrade to 8.17.0. But I am unable to continue down the path of upgrade to 10 due the above error.

Steps to reproduce

Have my 8.17.0 database Install a new Umbraco 10 project Hit upgrade, failed with the above exception

Expected result / actual result

Upgrade should be successful

github-actions[bot] commented 1 year ago

Hi there @halfer53!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

halfer53 commented 1 year ago

Complete log file: https://mega.nz/file/Fd8WmZSB#JColfshGyKR4Y3qOH5QNbUjkiM6pmLbe9yrm2GFsdv8

andr317c commented 1 year ago

Hey!

Thanks a lot for posting this issue 💪. I tried reproducing by upgrading a v 8.17.0 project with the clean starter kit installed to 10.5.1. And it worked. Are you able to provide us with your database so we can look further into the issue? 😄

halfer53 commented 1 year ago

@andr317c sure, how do I send the database to you?

andr317c commented 1 year ago

You can send a backpack of your database to my email: aze@umbraco.dk

andr317c commented 1 year ago

I looked further into the issue and found out that we have an issue with translating Chinese and some other special characters to a PropertyTypeGroup alias, the issue left some aliases empty which is why this upgrade failed.

I'm guessing that we did not have a validation checking if the PropertyTypeGroup alias was empty or not. in V7 and under.

To fix the missing aliases on your PropertyTypeGroup, go into your cmsPropertyTypeGroup table and add the missing aliases for the PropertyTypeGroups.

The actual issue happens when you try to input Chinese or some other special characters in the PropertyTypeGroup name for the first time and try to save it, the alias for the PropertyTypeGroup will be empty.

An example could be that you try to input "内容" as the PropertyTypeGroup name, when you input this, the alias will be empty. This will throw a validation error on V10 and up so you won't be able to save the document type, my guess would be that on earlier versions around V7 and under it did not throw an error, so you were allowed to save a PropertyTypeGroup with an empty alias. If you then try to write "内容内容" it will set the alias as "1" and it will save the document type. The alias should be translated to "1" the first time we input the PropertyTypeGroup name, and not the second time.

I will mark this issue as an up for grabs.

github-actions[bot] commented 1 year ago

Hi @halfer53,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post.

Thanks muchly, from your friendly Umbraco GitHub bot :-)

yawkale commented 1 year ago

possible workaround find all Property Type Group with empty alias and set it SELECT * FROM [cmsPropertyTypeGroup] WHERE [alias] is null