Open jixinwang01 opened 1 year ago
Nice find!
This might also quite possibly be related to or being the underlying root cause of the recently reported issue https://github.com/JamesNK/Newtonsoft.Json/issues/2850.
So when will this issue be fixed if we insist on using this attribute MetadataPropertyHandling.ReadAhead
hi elgonzo, briandesarmo
Haven't any else update?
Thanks.
hi elgonzo, briandesarmo
Haven't any else update?
Thanks.
We are working around this bug by using the MetadataPropertyHandling
default, instead of MetadataPropertyHandling.ReadAhead
.
Anyone can help on this issue?
I tried to update the MaxDepth but takes 64 as default and still facing the same issue here is the exception trace
[Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] [bd577466 ERR] [0HN23UCMHFS3P:00000003] [::1] An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Current error context error is different to requested error.
at ErrorContext Newtonsoft.Json.Serialization.JsonSerializerInternalBase.GetErrorContext(object currentObject, object member, string path, Exception error)
at bool Newtonsoft.Json.Serialization.JsonSerializerInternalBase.IsErrorHandled(object currentObject, JsonContract contract, object keyValue, IJsonLineInfo lineInfo, string path, Exception ex)
at object Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, bool checkAdditionalContent)
at object Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at async Task<InputFormatterResult> Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
at async Task<InputFormatterResult> Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonInputFormatter.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)
at async Task Microsoft.AspNetCore.Mvc.ModelBinding.Binders.BodyModelBinder.BindModelAsync(ModelBindingContext bindingContext)
at async ValueTask<ModelBindingResult> Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, object value, object container)
at void Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider+<>c__DisplayClass0_0+<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
at async Task Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()+Awaited(?)
at async Task Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter()+Awaited(?)
at void Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Task Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
at async Task Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()+Awaited(?)
at async Task Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeAsync()+Awaited(?)
at async Task Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeAsync()+Awaited(?)
at async Task Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at async Task Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at async Task Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at async Task Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at async Task Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at async Task IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)
at async Task IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
at async Task Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at async Task IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
The data that I am passing is 32 levels deep but due to the [FromBody] attribute in the parameter it read more than 64 and caused the above exception.
when will this issue be fixed? Thanks
Source/destination types
Expected behavior
MaxDepth is used with ISerializable deserialization when JsonSerializerSettings.MetadataPropertyHandling set MetadataPropertyHandling.ReadAhead
Actual behavior
Create new JTokenReader object and can't copy JsonReader MaxDepth to this object
Steps to reproduce