System.NullReferenceException in /_/src/Sentry.AspNetCore/SentryMiddleware.cs in roughly 1 in 100 requests
See original GitHub issueEnvironment
Sentry SaaS (sentry.io) Sentry SDK: .NET 3.3.4 Framework: ASP.NET Core 5.0 Deployed to Azure Web Apps
Steps to Reproduce
This issue only occurs sporadically (1 in 100 requests) and has only occurred 2 days after upgrading to 3.3.4
. I wasn’t able to reproduce this issue locally and so far has only occured on our Azure hosted instances.
- Inside
Program.Main()
we callwebBuilder.UseSentry()
with the generic .NET Host builder (source for reference) - Inside our Controller we call
SentrySdk.ConfigureScope()
like so:
public async Task<ActionResult<FullLessonData>> FetchLessonByLessonID(long lessonID)
{
var (status, lesson) = await _lessonModelGenerator.LessonByID(lessonID, User);
SentrySdk.ConfigureScope(scope =>
{
scope.SetExtra("lessonModelGenerator.responseStatus", status.ToString());
});
return status switch
{
LessonModelGenerator.ResponseStatus.OK => lesson == null ? Forbid() : Ok(lesson),
LessonModelGenerator.ResponseStatus.NoAccess => Forbid(),
LessonModelGenerator.ResponseStatus.NotFound => NotFound(),
_ => throw new NotImplementedException("LessonModelGenerator.ResponseStatus is not handled")
};
}
- In roughly 1 in 100 requests, we receive a
System.NullReferenceException
inFile "/_/src/Sentry.AspNetCore/SentryMiddleware.cs", line 139, col 9, in async Task SentryMiddleware.InvokeAsync(HttpContext context)
(The full sentry log + callstack for reference.)
Expected Result
No exception is thrown during normal operations
Actual Result
Raw JSON of the sentry event that captures the exception including callstack
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
How can I fix the error: System.NullReferenceException
A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. A NullReferenceException exception ......
Read more >Random NullReferenceException on Asp.Net Core 2.1.1 ...
For the majority of requests it works as expected. Randomly (approximately 1-5 out of 100 requests) it results in a NullReferenceException.
Read more >Failed to extract body - NullReferenceException #1701
System.NullReferenceException: Object reference not set to an instance of an ... ExtractPayload(IHttpRequest request) in /_/src/Sentry/ ...
Read more >object reference not set to an instance of an object.
Everything seems to work fine up until enabling the components, which I get a NullReferenceException in the console.
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
metadata
indeed comes from the ingestion pipeline. It is generated here and written here. They are used by the Sentry UI to render issue titles among other things.They are definitely unrelated to any SDK problems.
@bruno-garcia so based on that, this should be closed as not related to sentry?