Avoid logging bad requests as application errors if the connection was aborted#60359
Merged
adityamandaleeka merged 5 commits intodotnet:mainfrom Feb 20, 2025
Merged
Conversation
Member
|
Unit tests? One where the message is logged (open connection) and another that verifies it isn't (closed connection) |
150c32e to
e6d4ca8
Compare
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. |
JamesNK
reviewed
Feb 20, 2025
JamesNK
approved these changes
Feb 20, 2025
3 tasks
BrennanConroy
approved these changes
Feb 20, 2025
|
Is this change included in asp.net 8 ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.BadRequestsso 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