dotnet / dotnet/aspnetcore

DefaultHttpResponse throws null ref when trying to access StatusCode (inside the AspNetCore library)

Open
#52,760 7 comments 0 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

We are experiencing a very similar issue to https://github.com/dotnet/aspnetcore/issues/25454.

During the health check liveness probe, we sometimes encounter an "Object reference not set to an instance of an object." exception. However, it's important to note that this exception is not occurring within our code (as it did in the related ticket) but rather inside the AspNetCore library.

### Expected Behavior

_No response_

### Steps To Reproduce

Unfortunately, I was unable to find a way to reproduce the issue locally, but it does occur intermittently in our production environment, although not very frequently

### Exceptions (if any)

NullReferenceException: Object reference not set to an instance of an object.

at Microsoft.AspNetCore.Http.DefaultHttpResponse.get_StatusCode() at App.Metrics.AspNetCore.Tracking.Middleware.ErrorRequestMeterMiddleware.Invoke(HttpContext context) at App.Metrics.AspNetCore.Tracking.Middleware.ActiveRequestCounterEndpointMiddleware.Invoke(HttpContext context) at App.Metrics.AspNetCore.Tracking.Middleware.ApdexMiddleware.MeasureTransaction(HttpContext context) at App.Metrics.AspNetCore.Tracking.Middleware.PerRequestTimerMiddleware.TimeTransaction(HttpContext context) at App.Metrics.AspNetCore.Tracking.Middleware.RequestTimerMiddleware.TimeTransaction(HttpContext context) at App.Metrics.AspNetCore.Tracking.Middleware.ErrorRequestMeterMiddleware.Invoke(HttpContext context) at App.Metrics.AspNetCore.Tracking.Middleware.ActiveRequestCounterEndpointMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

### .NET Version

7.0.5

### Anything else?

Host:
Version: 7.0.5
Architecture: x64
Commit: 8042d61b17

.NET SDKs installed:
No SDKs were found.

.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.