Failed to extract body - NullReferenceException
See original GitHub issuePackage
Sentry.AspNetCore
.NET Flavor
.NET
.NET Version
6.0.201
OS
Windows
SDK Version
3.16.0
Self-Hosted Sentry Version
No response
Steps to Reproduce
We could not reproduce the issue, it happens randomly and seldomly but it makes the server crash
Expected Result
The error should be triggered only once
Actual Result
It seems that NLog logs properly but when sending the log to Sentry it enters in a infinite loop.
2022-06-06 10:25:29.7338|ERROR|App.Controllers.StudyController|Unhandled controller exception: Object reference not set to an instance of an object.|System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_BodyReader()
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Mvc.ModelBinding.FormValueProviderFactory.AddValueProviderAsync(ValueProviderFactoryContext context)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.CreateAsync(ActionContext actionContext, IList`1 factories)
at Microsoft.AspNetCore.Mvc.ModelBinding.CompositeValueProvider.TryCreateAsync(ActionContext actionContext, IList`1 factories)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2022-06-06 10:25:29.8449|ERROR|Sentry.ISentryClient|Failed to extract body.|System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_BodyReader()
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Form()
at Sentry.AspNetCore.HttpRequestAdapter.get_Form() in /_/src/Sentry.AspNetCore/HttpRequestAdapter.cs:line 17
at Sentry.Extensibility.FormRequestPayloadExtractor.DoExtractPayLoad(IHttpRequest request) in /_/src/Sentry/Extensibility/FormRequestPayloadExtractor.cs:line 24
at Sentry.Extensibility.BaseRequestPayloadExtractor.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/BaseRequestPayloadExtractor.cs:line 33
at Sentry.Extensibility.RequestBodyExtractionDispatcher.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/RequestBodyExtractionDispatcher.cs:line 53
at Sentry.AspNetCore.ScopeExtensions.SetBody(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 163
at Sentry.AspNetCore.ScopeExtensions.Populate(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 55
2022-06-06 10:25:29.9017|ERROR|Sentry.ISentryClient|Failed to extract body.|System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_BodyReader()
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Form()
at Sentry.AspNetCore.HttpRequestAdapter.get_Form() in /_/src/Sentry.AspNetCore/HttpRequestAdapter.cs:line 17
at Sentry.Extensibility.FormRequestPayloadExtractor.DoExtractPayLoad(IHttpRequest request) in /_/src/Sentry/Extensibility/FormRequestPayloadExtractor.cs:line 24
at Sentry.Extensibility.BaseRequestPayloadExtractor.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/BaseRequestPayloadExtractor.cs:line 33
at Sentry.Extensibility.RequestBodyExtractionDispatcher.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/RequestBodyExtractionDispatcher.cs:line 53
at Sentry.AspNetCore.ScopeExtensions.SetBody(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 163
at Sentry.AspNetCore.ScopeExtensions.Populate(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 55
2022-06-06 10:25:29.9461|ERROR|Sentry.ISentryClient|Failed to extract body.|System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_BodyReader()
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Form()
at Sentry.AspNetCore.HttpRequestAdapter.get_Form() in /_/src/Sentry.AspNetCore/HttpRequestAdapter.cs:line 17
at Sentry.Extensibility.FormRequestPayloadExtractor.DoExtractPayLoad(IHttpRequest request) in /_/src/Sentry/Extensibility/FormRequestPayloadExtractor.cs:line 24
at Sentry.Extensibility.BaseRequestPayloadExtractor.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/BaseRequestPayloadExtractor.cs:line 33
at Sentry.Extensibility.RequestBodyExtractionDispatcher.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/RequestBodyExtractionDispatcher.cs:line 53
at Sentry.AspNetCore.ScopeExtensions.SetBody(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 163
at Sentry.AspNetCore.ScopeExtensions.Populate(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 55
2022-06-06 10:25:30.0173|ERROR|Sentry.ISentryClient|Failed to extract body.|System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_BodyReader()
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Form()
at Sentry.AspNetCore.HttpRequestAdapter.get_Form() in /_/src/Sentry.AspNetCore/HttpRequestAdapter.cs:line 17
at Sentry.Extensibility.FormRequestPayloadExtractor.DoExtractPayLoad(IHttpRequest request) in /_/src/Sentry/Extensibility/FormRequestPayloadExtractor.cs:line 24
at Sentry.Extensibility.BaseRequestPayloadExtractor.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/BaseRequestPayloadExtractor.cs:line 33
at Sentry.Extensibility.RequestBodyExtractionDispatcher.ExtractPayload(IHttpRequest request) in /_/src/Sentry/Extensibility/RequestBodyExtractionDispatcher.cs:line 53
at Sentry.AspNetCore.ScopeExtensions.SetBody(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 163
at Sentry.AspNetCore.ScopeExtensions.Populate(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in /_/src/Sentry.AspNetCore/ScopeExtensions.cs:line 55
2022-06-06 10:25:30.0571|ERROR|Sentry.ISentryClient|Failed to extract body.|System.
Issue Analytics
- State:
- Created a year ago
- Comments:20 (7 by maintainers)
Top Results From Across the Web
c# - What is a NullReferenceException, and how do I fix it?
The message "Object not set to an instance of Object" means you are trying to use an object which has not been initialized....
Read more >Failed to extract body due to: javax.jms.JMSException
Hi Guys I'm using a HornetQ and SwitchYard to implement JMS messages and topics. The system works ok, but in several hours after...
Read more >how to extract error message from the error payload also i ...
when i call it using vars.returnpayloaderror i am not getting the value.Though it is not getting any value atleast it should store null...
Read more >How can I fix the error: System.NullReferenceException
When you have a statement like A.B.C = E.F; , and you receive an NullReferenceException 'Object reference not set to an instance of...
Read more >Java NullPointerException - Detect, Fix, and Best Practices
When we run the above program, it throws the following NullPointerException error message. Exception in thread "main" java.lang.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/NLog/NLog.Web/pull/754
This was removed outright in NLog.Web.AspNetCore 5.0 due to these issues. I added a PR to fix aspnet-request-posted-body for NLog.Web.AspNetCore 5.1, it requires you to install an ASP.NET Middleware class we added the NLog.Web.AspnetCore to capture the request, that way it is thread safe. I have been using that way to capture both the request and response body at my work for that past 2 years and have had no issues under load. Just remember to use it for requests only less than 30 KB in length. Above that ASP.NET Core HttpRequest.EnableBuffering() writes to TEMP files, according to its documentation. Therefore, our default request length above which we refuse to capture the request body is therefore 30 KB, but you could override that if you want to live dangerously. (I also added about a dozen more layout renderers for asp.net and asp.net core for the upcoming release). We are also adding an example to the wiki for response body capturing middleware. If you need it re-activated before the release I can show you how to add the request middleware class and log the request body to HttpContext.Items, then use one of the existing layout renders that prints an HttpContext.Item out.