Closed jsonarso closed 3 years ago
I'm currently working on the PagerShapes
And I got the exact same exception
Repro
Older posts
=> you get the exception@antonysb27 please feel free to add any further details you might consider important.
No problem, I'm trying it, i will let you know if i find anything
Issue is related with latest merged changes in shapes with Fluid 2.0 I noticed this one last week.
// specific cross-requests route data can be passed to the shape directly (e.g., OrchardCore.Users)
var shapeRoute = shape.GetProperty("RouteData");
Issue was there if I remember correctly.
For my use case, i tried it before Fluid 2.0, same issue, i'm working on it
I found a fix at least for my use case
It was failing when using a StringHtmlContent
in the inner html of a TagBuilder
Still working on it as i need to understand why
@jason8496as
I did a PR #8894 that fixes my use case but maybe not yours
As i can see in your trace, even it is the same exception, it doesn't seem to be the exact same source
Can you copy paste your stack trace, i can't see the details in your image
In your site pages, are you using a pager and under liquid?
@jtkech The complete stack trace is as follows:
ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index') Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers.ViewBufferTextWriter.Write(char[] buffer, int index, int count)
Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers.ViewBufferTextWriter.Write(char[] buffer, int index, int count)
System.IO.TextWriter.Write(ReadOnlySpan<char> buffer)
System.IO.TextWriterExtensions.WritePartialString(TextWriter writer, string value, int offset, int count)
System.Text.Encodings.Web.TextEncoder.Encode(TextWriter output, string value, int startIndex, int characterCount)
System.Text.Encodings.Web.TextEncoder.Encode(TextWriter output, string value)
Fluid.Values.StringValue.WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
Fluid.Ast.OutputStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context)
Fluid.BaseFluidTemplate<T>.Awaited(ValueTask<Completion> task, TextWriter writer, TextEncoder encoder, TemplateContext context, List<Statement> statements, int startIndex)
System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult()
OrchardCore.DisplayManagement.Liquid.LiquidViewTemplate.RenderAsync(RazorPage<object> page) in LiquidViewTemplate.cs
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.HtmlHelper.RenderPartialCoreAsync(string partialViewName, object model, ViewDataDictionary viewData, TextWriter writer)
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.PartialAsync(string partialViewName, object model, ViewDataDictionary viewData)
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.<ProcessAsync>g__Awaited|12_0(Task<IHtmlContent> task) in DefaultHtmlDisplay.cs
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context) in DefaultHtmlDisplay.cs
OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context) in DefaultHtmlDisplay.cs
CallSite.Target(Closure , CallSite , object )
System.Dynamic.UpdateDelegates.UpdateAndExecute1<T0, TRet>(CallSite site, T0 arg0)
AspNetCore._Areas_OrchardCore_Contents_Views_Item_Display.ExecuteAsync() in Display.cshtml
+
@await DisplayAsync(Model)
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.<InvokeResultAsync>g__Logged|21_0(ResourceInvoker invoker, IActionResult result)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_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|27_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_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|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
OrchardCore.Diagnostics.DiagnosticsStartupFilter+<>c__DisplayClass3_0+<<Configure>b__1>d.MoveNext() in DiagnosticsStartupFilter.cs
Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
OrchardCore.ContentPreview.PreviewStartupFilter+<>c+<<Configure>b__1_1>d.MoveNext() in PreviewStartupFilter.cs
OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext) in ModularTenantRouterMiddleware.cs
OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func<ShellScope, Task> execute) in ShellScope.cs
OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext) in ModularTenantContainerMiddleware.cs
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')
at Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers.ViewBufferTextWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.Write(ReadOnlySpan`1 buffer)
at System.IO.TextWriterExtensions.WritePartialString(TextWriter writer, String value, Int32 offset, Int32 count)
at System.Text.Encodings.Web.TextEncoder.Encode(TextWriter output, String value, Int32 startIndex, Int32 characterCount)
at System.Text.Encodings.Web.TextEncoder.Encode(TextWriter output, String value)
at Fluid.Values.StringValue.WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
at Fluid.Ast.OutputStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context)
at Fluid.BaseFluidTemplate`1.Awaited(ValueTask`1 task, TextWriter writer, TextEncoder encoder, TemplateContext context, List`1 statements, Int32 startIndex)
at OrchardCore.DisplayManagement.Liquid.LiquidViewTemplate.RenderAsync(RazorPage`1 page) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.DisplayManagement.Liquid\LiquidViewTemplate.cs:line 128
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
at Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.RenderPartialCoreAsync(String partialViewName, Object model, ViewDataDictionary viewData, TextWriter writer)
at Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.PartialAsync(String partialViewName, Object model, ViewDataDictionary viewData)
at OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.<ProcessAsync>g__Awaited|12_0(Task`1 task) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.DisplayManagement\Implementation\DefaultHtmlDisplay.cs:line 296
at OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.DisplayManagement\Implementation\DefaultHtmlDisplay.cs:line 116
at OrchardCore.DisplayManagement.Implementation.DefaultHtmlDisplay.ExecuteAsync(DisplayContext context) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.DisplayManagement\Implementation\DefaultHtmlDisplay.cs:line 174
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at AspNetCore._Areas_OrchardCore_Contents_Views_Item_Display.ExecuteAsync() in /Areas/OrchardCore.Contents/Views/Item/Display.cshtml:line 7
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|21_0(ResourceInvoker invoker, IActionResult result)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|27_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_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>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at OrchardCore.Diagnostics.DiagnosticsStartupFilter.<>c__DisplayClass3_0.<<Configure>b__1>d.MoveNext() in C:\projects\orchardcore\src\OrchardCore.Modules\OrchardCore.Diagnostics\DiagnosticsStartupFilter.cs:line 36
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
at OrchardCore.ContentPreview.PreviewStartupFilter.<>c.<<Configure>b__1_1>d.MoveNext() in C:\projects\orchardcore\src\OrchardCore.Modules\OrchardCore.ContentPreview\PreviewStartupFilter.cs:line 23
--- End of stack trace from previous location where exception was thrown ---
at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext) in C:\projects\orchardcore\src\OrchardCore\OrchardCore\Modules\ModularTenantRouterMiddleware.cs:line 63
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute) in C:\projects\orchardcore\src\OrchardCore\OrchardCore.Abstractions\Shell\Scope\ShellScope.cs:line 206
at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext) in C:\projects\orchardcore\src\OrchardCore\OrchardCore\Modules\ModularTenantContainerMiddleware.cs:line 59
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
In your site pages, are you using a pager and under liquid?
We are using a custom paging in the Blog-ListPart.liquid
page, but it does not use the Model.Pager
.
@jason8496as @antonysb27
Okay thanks for the infos
So in my use case i needed to update somewhere what the StringHtmlContent
does
encoder.Encode(writer, _input);
by using a new class doing
writer.Write(encoder.Encode(_value))
Here in your trace we see the usage of a Fluid StringValue
and in the source code we can see that the same update has been done on Feb 6, 2021
https://github.com/sebastienros/fluid/blob/ad942870db05bf7f57b23e4d77fa628ec780a891/Fluid/Values/StringValue.cs#L149-L156
// perf: Don't use this overload
// encoder.Encode(writer, _value);
// Use a transient string instead of calling
// encoder.Encode(TextWriter) since it would
// call writer.Write on each char if the string
// has even a single char to encode
writer.Write(encoder.Encode(_value));
So my question is which version of OrchardCore are you using?
@jtkech
We are using OrchardCore version 1.0.0-rc2-13450
specifically.
Regarding the update you are talking about, I noticed that it was included in Fluid v2.0.0-beta-1009
and v2.0.0-beta-1010
pre-releases but we have the following referenced in our project:
<PackageManagement Include="Fluid.Core" Version="1.0.0-beta-9651" />
Ah Okay, so you are using the master branch (nuget feed)
If you can repro locally, would be good to re-try it with the last dev branch (cloudsmith feed)
We actually are experiencing the same weird issues here.
We have been using Orchard Core CMS 1.0.0-rc2-13450 (latest stable) since June 2020 on different environments, including Azure App Service (Windows), dedicated server with Windows Server 2012 R2 Standard, dev machines with Windows 10 Pro (20H2). Suddenly, approx. in the middle of March 2021 we started to get a lot of "An error has occurred..." output for some content parts and some weird output for another content parts in all the environments we have. No content changes or code updates were done to cause it.
Steps to reproduce for Orchard Core CMS 1.0.0-rc2-13450 (standard TheBlog theme):
Økonomi
(in Norwegian).
Expected: Økonomi
content is displayed properly.
Actual: ')">
is displayed on the page instead of Økonomi
.
Økonomi
(in Norwegian).
Expected: The page's content is displayed properly. Actual: An unhandled exception occurred while processing the request. ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index').
The latest available Orchard Core CMS 1.0.0-rc2-16010 fixes most of these issues, but not all of them. For example:
{% meta property:"og:description", content: "Økonomi" %}
Note: it is important that the first character in the content string is a character that should be HTML encoded.
Expected: <meta content="Økonomi" property="og:description" />
is rendered in the header;
Actual: An unhandled exception occurred while processing the request. ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index').
It looks like the trigger for these issues can be the recent .NET March 2021 Updates – 5.0.4, 3.1.13, 2.1.26 which were distributed (via Windows Update ?) to all our environments. It is a wild guess though, we haven't had time to prove/disprove this suspicion yet.
Hope it helps.
@Voskoboynik and all others, thanks for the info
The latest available Orchard Core CMS 1.0.0-rc2-16010 fixes most of these issues
Good to know !!!
but not all of them.
Yes maybe some others IHtmlContent
doing a encoder.Encode(writer, _value)
that seems to be problematic, and that we could replace, and / or something else related to Fuild / Liquid.
Hmm, here seems to be related to an HtmlContentBuilder
used by the our ResourcesTag
I will try to repro this night, thanks for the feedback
@Voskoboynik
Okay i could repro with {% meta property:"og:description", content: "Økonomi" %}
in a liquid page body
We will fix it soon, thanks
cloudsmith
@jtkech
I just installed the latest package from cloudsmtih (1.0.0-rc2-16015
) https://cloudsmith.io/~orchardcore/repos/preview/packages/detail/nuget/OrchardCore.Application.Cms.Targets/
Now I'm getting this assembly error.
I tried to install the OrchardCore.ResourceManagement.Abstractions
package from the same feed but I'm not being able to repro locally.
Any idea?
@jason8496as
Yes, it has been changed, see the updated doc https://docs.orchardcore.net/en/dev/docs/reference/modules/Resources/#registering-a-resource-manifest
For info i fixed the above issue on my local machine, just need to find the best way before committing
For info i fixed the above issue on my local machine, just need to find the best way before committing
@jtkech Thank you for the fix!
I confirm there is a bug in aspnet mvc that is triggered by the recent servicing updates, due to how the html encoder is invoking the html buffers in MVC. @jtkech 's changes to use our internal HtmlContentString
mitigates this issue. I don't think we will provide a fix for rc2 though, it's a bug in dotnet specifically. It's not related to Fluid changes either. An option could be to force the reference to the previous System.Text.Encoding.Web, but this one has a security vulnerability.
@Voskoboynik if this can help you in any way.
We validated that the issue occurs when the ASP.NET Core Runtime 3.1.13 version is used. So, we decided as a workaround to publish the application, which uses the RC2, as a self-contained deployment using the ASP.NET Core Runtime 3.1.10 and now it is working well in the Azure app service. We also validated that using the ASP.NET Core Runtime 3.1.11 version the application still works.
All, a possible workaround is coming, see #8984
Describe the bug
We have been using Orchard Core CMS 1.0.0-rc2 to develop a brand new website.
Recently we discovered an interesting issue that only happens when upgrading the Visual Studio version and doesn't let us visualize some of the site pages.
We are not pretty sure if it has something to do with the IDE itself or maybe with any of the individual components that it install when upgrading.
The admin portal can be accessed and all of the content is shown within it, but when trying to open some site pages we get the following error.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The website is working as expected and every single page can be accessed using older versions of Visual Studio, for example, version 16.8.3.
Screenshots