Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid logging bad requests as application errors if the connection was aborted #60359

Merged

Conversation

adityamandaleeka
Copy link
Member

Change the behavior in Kestrel's request processing logic so that bad requests are only logged as errors if the connection has not been aborted. This reduces noise in the logs for common client errors.

We already expose bad request information via Microsoft.AspNetCore.Server.Kestrel.BadRequests so anyone who is interested in seeing all of this already has a mechanism for doing so, and we don't show scary "fail" messages to people who don't care.

This issue has been a source of great frustration for years now (#23949), and generally, there's nothing the server dev can do when there's an unexpected client behavior (e.g. aborting a connection before completing a request) so this seems like a sane default.

Fix #23949

@Copilot Copilot bot review requested due to automatic review settings February 13, 2025 02:38
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@JamesNK
Copy link
Member

JamesNK commented Feb 13, 2025

Unit tests? One where the message is logged (open connection) and another that verifies it isn't (closed connection)

@adityamandaleeka
Copy link
Member Author

Added a new test for the aborted connection scenario and piggybacked on an existing one for the other case where we want to keep the message the same.

@adityamandaleeka adityamandaleeka merged commit ed01b60 into dotnet:main Feb 20, 2025
24 of 27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview3 milestone Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Unexpected end of request content.
3 participants