Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.9.0-preview-18132 Exception with backend and with frontend #15565

Closed
bashuss opened this issue Mar 21, 2024 · 8 comments · Fixed by #15571
Closed

1.9.0-preview-18132 Exception with backend and with frontend #15565

bashuss opened this issue Mar 21, 2024 · 8 comments · Fixed by #15571
Assignees
Labels

Comments

@bashuss
Copy link

bashuss commented Mar 21, 2024

Describe the bug

For testing the latest Navbar changes I tried build against the preview source 1.9.0-preview-18132.

with "/admin" url, I get:

An unhandled exception occurred while processing the request.
NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'OrchardCore.Sitemaps.Models.SitemapSource'.
Unknown location

NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'OrchardCore.Sitemaps.Models.SitemapSource'. Path: $.Sitemaps.4t94tmv1b84y11wn5dndnzcyn7.SitemapSources[0] | LineNumber: 0 | BytePositionInLine: 237.
System.Text.Json.ThrowHelper.ThrowNotSupportedException(ref ReadStack state, ref Utf8JsonReader reader, NotSupportedException ex)

Stack Query Cookies Headers Routing
NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'OrchardCore.Sitemaps.Models.SitemapSource'.

Show raw exception details
NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'OrchardCore.Sitemaps.Models.SitemapSource'. Path: $.Sitemaps.4t94tmv1b84y11wn5dndnzcyn7.SitemapSources[0] | LineNumber: 0 | BytePositionInLine: 237.
System.Text.Json.ThrowHelper.ThrowNotSupportedException(ref ReadStack state, ref Utf8JsonReader reader, NotSupportedException ex)
System.Text.Json.ThrowHelper.ThrowNotSupportedException_DeserializeNoConstructor(JsonTypeInfo typeInfo, ref Utf8JsonReader reader, ref ReadStack state)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<T>.OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value)
System.Text.Json.Serialization.JsonConverter<T>.TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value, out bool isPopulatedValue)
System.Text.Json.Serialization.JsonCollectionConverter<TCollection, TElement>.OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out TCollection value)
System.Text.Json.Serialization.JsonConverter<T>.TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value, out bool isPopulatedValue)
System.Text.Json.Serialization.Metadata.JsonPropertyInfo<T>.ReadJsonAndSetMember(object obj, ref ReadStack state, ref Utf8JsonReader reader)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<T>.OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value)
System.Text.Json.Serialization.JsonConverter<T>.OnTryReadAsObject(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out object value)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<T>.OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value)
System.Text.Json.Serialization.JsonConverter<T>.TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value, out bool isPopulatedValue)
System.Text.Json.Serialization.JsonDictionaryConverter<TDictionary, TKey, TValue>.OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out TDictionary value)
System.Text.Json.Serialization.JsonConverter<T>.TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value, out bool isPopulatedValue)
System.Text.Json.Serialization.Metadata.JsonPropertyInfo<T>.ReadJsonAndSetMember(object obj, ref ReadStack state, ref Utf8JsonReader reader)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<T>.ReadPropertyValue(object obj, ref ReadStack state, ref Utf8JsonReader reader, JsonPropertyInfo jsonPropertyInfo, bool useExtensionProperty)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<T>.PopulatePropertiesFastPath(object obj, JsonTypeInfo jsonTypeInfo, JsonSerializerOptions options, ref Utf8JsonReader reader, ref ReadStack state)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter<T>.OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value)
System.Text.Json.Serialization.JsonConverter<T>.TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T value, out bool isPopulatedValue)
System.Text.Json.Serialization.JsonConverter<T>.ReadCore(ref Utf8JsonReader reader, JsonSerializerOptions options, ref ReadStack state)
System.Text.Json.Serialization.Metadata.JsonTypeInfo<T>.Deserialize(ref Utf8JsonReader reader, ref ReadStack state)
System.Text.Json.Serialization.Metadata.JsonTypeInfo<T>.DeserializeAsObject(ref Utf8JsonReader reader, ref ReadStack state)
System.Text.Json.JsonSerializer.ReadFromSpanAsObject(ReadOnlySpan<byte> utf8Json, JsonTypeInfo jsonTypeInfo, Nullable<int> actualByteCount)
System.Text.Json.JsonSerializer.ReadFromSpanAsObject(ReadOnlySpan<char> json, JsonTypeInfo jsonTypeInfo)
System.Text.Json.JsonSerializer.Deserialize(string json, Type returnType, JsonSerializerOptions options)
YesSql.Serialization.DefaultJsonContentSerializer.Deserialize(string content, Type type)
YesSql.Session.Get<T>(IList<Document> documents, string collection)
YesSql.Services.DefaultQuery+Query<T>.FirstOrDefaultImpl()
YesSql.Services.DefaultQuery+Query<T>.FirstOrDefaultImpl()
OrchardCore.Data.Documents.DocumentStore.GetOrCreateImmutableAsync<T>(Func<Task<T>> factoryAsync)
OrchardCore.Documents.DocumentManager<TDocument>.GetOrCreateImmutableAsync(Func<Task<TDocument>> factoryAsync)
OrchardCore.Sitemaps.Services.SitemapManager.GetIdentifierAsync()
OrchardCore.Sitemaps.Routing.SitemapEntries.TryGetSitemapIdByPathAsync(string path)
OrchardCore.Sitemaps.Routing.SitemapRouteTransformer.TransformAsync(HttpContext httpContext, RouteValueDictionary values)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
Microsoft.AspNetCore.Mvc.Routing.DynamicControllerEndpointMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)
Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|10_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
OrchardCore.Diagnostics.DiagnosticsStartupFilter+<>c__DisplayClass3_0+<<Configure>b__1>d.MoveNext()
Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
OrchardCore.ContentPreview.PreviewStartupFilter+<>c+<<Configure>b__0_1>d.MoveNext()
OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
OrchardCore.Modules.ModularTenantContainerMiddleware+<>c__DisplayClass4_0+<<Invoke>b__0>d.MoveNext()
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Expected behavior

Backend should have shown, or the login page
worked with Version 1.8.2

@bashuss
Copy link
Author

bashuss commented Mar 21, 2024

When trying to open the homepage frontend url, i get

An unhandled exception occurred while processing the request.
Exception: Shape type 'menu2' not found
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context)

Stack Query Cookies Headers Routing
Exception: Shape type 'menu2' not found
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context)
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context)
OrchardCore.DisplayManagement.Liquid.Filters.ShapeRenderFilter.<ProcessAsync>g__Awaited|2_0(Task<IHtmlContent> task)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
Fluid.Ast.FilterExpression.EvaluateAsync(TemplateContext context)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
Fluid.Ast.OutputStatement.<WriteToAsync>g__Awaited|7_0(ValueTask<FluidValue> t, TextWriter w, TextEncoder enc, TemplateContext ctx)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Fluid.FluidParserExtensions.<RenderStatementsAsync>g__Awaited|3_0(ValueTask<Completion> task, int startIndex, IReadOnlyList<Statement> statements, TextWriter writer, TextEncoder encoder, TemplateContext context)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
OrchardCore.DisplayManagement.Liquid.Tags.ZoneTag.WriteToAsync(List<FilterArgument> argumentsList, IReadOnlyList<Statement> statements, TextWriter writer, TextEncoder encoder, TemplateContext context)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Fluid.Parser.FluidTemplate.Awaited(ValueTask<Completion> task, TextWriter writer, TextEncoder encoder, TemplateContext context, IReadOnlyList<Statement> statements, int startIndex)
OrchardCore.DisplayManagement.Liquid.LiquidViewTemplateExtensions.RenderAsync(LiquidViewTemplate template, TextWriter writer, TextEncoder encoder, LiquidTemplateContext context, object model)
OrchardCore.Liquid.Services.LiquidTemplateManager.RenderHtmlContentAsync(string source, TextEncoder encoder, object model, IEnumerable<KeyValuePair<string, FluidValue>> properties)
OrchardCore.Templates.Services.TemplatesShapeBindingResolver+<>c__DisplayClass8_0+<<BuildShapeBinding>b__0>d.MoveNext()
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.<ProcessAsync>g__Awaited|11_0(Task<IHtmlContent> task)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context)
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context)
OrchardCore.DisplayManagement.Liquid.Filters.ShapeRenderFilter.<ProcessAsync>g__Awaited|2_0(Task<IHtmlContent> task)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
Fluid.Ast.FilterExpression.EvaluateAsync(TemplateContext context)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
Fluid.Ast.OutputStatement.<WriteToAsync>g__Awaited|7_0(ValueTask<FluidValue> t, TextWriter w, TextEncoder enc, TemplateContext ctx)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Fluid.Parser.FluidTemplate.Awaited(ValueTask<Completion> task, TextWriter writer, TextEncoder encoder, TemplateContext context, IReadOnlyList<Statement> statements, int startIndex)
OrchardCore.DisplayManagement.Liquid.LiquidViewTemplateExtensions.RenderAsync(LiquidViewTemplate template, TextWriter writer, TextEncoder encoder, LiquidTemplateContext context, object model)
OrchardCore.Liquid.Services.LiquidTemplateManager.RenderHtmlContentAsync(string source, TextEncoder encoder, object model, IEnumerable<KeyValuePair<string, FluidValue>> properties)
OrchardCore.Templates.Services.TemplatesShapeBindingResolver+<>c__DisplayClass8_0+<<BuildShapeBinding>b__0>d.MoveNext()
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.<ProcessAsync>g__Awaited|11_0(Task<IHtmlContent> task)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context)
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context)
CallSite.Target(Closure , CallSite , object )
System.Dynamic.UpdateDelegates.UpdateAndExecute1<T0, TRet>(CallSite site, T0 arg0)
AspNetCoreGeneratedDocument.Views_Item_Display.ExecuteAsync()
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|28_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
OrchardCore.Seo.Services.RobotsMiddleware.Invoke(HttpContext httpContext)
SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, bool retry)
OrchardCore.Liquid.ScriptsMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
OrchardCore.Diagnostics.DiagnosticsStartupFilter+<>c__DisplayClass3_0+<<Configure>b__1>d.MoveNext()
Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
OrchardCore.ContentPreview.PreviewStartupFilter+<>c+<<Configure>b__0_1>d.MoveNext()
OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
OrchardCore.Modules.ModularTenantContainerMiddleware+<>c__DisplayClass4_0+<<Invoke>b__0>d.MoveNext()
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute, bool activateShell)
OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

This also worked fine in Version 1.8.2.
The "menu2" shape is defined in templates in the backend as liquid shape.

@MikeAlhayek
Copy link
Member

It sounds like a System.Text.Json issue. Did you follow the instructions in 1.9 breaking changes to ensure your project is correctly converted?

https://docs.orchardcore.net/en/latest/docs/releases/1.9.0/

@hishamco
Copy link
Member

It sounds like a System.Text.Json issue.

Again :) I thought it was related to Navbar shape

@MikeAlhayek
Copy link
Member

@bashuss can you please try adding this into your project and see if this works for you?

services.AddJsonDerivedTypeInfo<CustomPathSitemapSource,SitemapSource>();

services.AddJsonDerivedTypeInfo<ContentTypesSitemapSource,SitemapSource>();

services.AddJsonDerivedTypeInfo<SitemapIndexSource,SitemapSource>();

@MikeAlhayek
Copy link
Member

@bashuss can you please try adding this into your project and see if this works for you?

services.AddJsonDerivedTypeInfo<CustomPathSitemapSource,SitemapSource>();

services.AddJsonDerivedTypeInfo<ContentTypesSitemapSource,SitemapSource>();

services.AddJsonDerivedTypeInfo<SitemapIndexSource,SitemapSource>();

@bashuss this indeed solve the problem. Update your packages to the latest to and you don't need to add the above 3 lines into your project. After adding that, if you still face the problem you can solve it by editing the database record manually. This means you create a sitemap index in 1.9.0 preview. To fix it do one of the following

  1. Remove the existing sitemaps by executing this query directly on your database DELETE FROM Document WHERE Type = 'OrchardCore.Sitemaps.Models.SitemapDocument, OrchardCore.Sitemaps'
  2. Or, find the document and update it manually like this `SELECT * FROM Document WHERE Type = 'OrchardCore.Sitemaps.Models.SitemapDocument, OrchardCore.Sitemaps'``

In that JSON document find something like this

"SitemapSources":[
                {
                    "Id":"some id...."
                }
            ],

and change it to this instead

"SitemapSources":[
                {
                    "$type":"OrchardCore.Sitemaps.Models.SitemapIndexSource, OrchardCore.Sitemaps",
                    "Id":"some id...."
                }
            ],

@hishamco
Copy link
Member

@MikeAlhayek can we leave this open until we get author feedback?

@MikeAlhayek
Copy link
Member

The issue was auto closed after merging the PR that fixed it. If there is an issue, feel free to re-open it. The PR fixes the reported issue.

@bashuss
Copy link
Author

bashuss commented May 28, 2024

@MikeAlhayek : Sorry, was very busy lately.
I just retried with OC 2.0.0-preview-18222

I corrected the breaking changes in my code and the /admin starts fine. The frontend problem is unfortunately still the same (#15565 (comment)).
The missing "menu2" shape is a shape defined as a liquid template in backend.

The causing problem seems to be, that these names are now case sensitive and they seem to have not been case sensitive before. The actual template is called "Menu2", but it was created in liquid with a lower case name "menu2", which seemed to have worked in 1.7.2 and 1.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants