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

Http.Sys: Clean up Request parsing errors #57531

Merged
merged 3 commits into from
Sep 12, 2024
Merged

Conversation

BrennanConroy
Copy link
Member

Http.Sys: Clean up Request parsing errors

Description

There are a few errors logged in the event that request processing fails. Additionally, there isn't a clean error on the client side when this occurs.

This change catches the errors earlier, logs a Debug level log, and sends an Http 400 response.

Customer Impact

Better client-side error and removes potential Error level logs on the server.

Regression?

  • Yes
  • No

Regressed in 6.0

Risk

  • High
  • Medium
  • Low

The change does not affect happy path scenarios and is limited to improved exception handling for non-happy path scenarios. Test added to verify new behavior. Lots of manual testing was done with individual parts of the change to make sure everything worked well.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@BrennanConroy BrennanConroy added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Aug 26, 2024
@BrennanConroy BrennanConroy added this to the 9.0-rc2 milestone Aug 26, 2024
@BrennanConroy BrennanConroy added the Servicing-approved Shiproom has approved the issue label Aug 27, 2024
@@ -142,6 +136,7 @@ public async Task Request_OverlongUTF8Path(string requestPath, string expectedPa
[InlineData("/", "/", "", "/")]
[InlineData("/base", "/base", "/base", "")]
[InlineData("/base", "/baSe", "/baSe", "")]
[InlineData("/base", "/baSe/", "/baSe", "/")]
Copy link
Member Author

Choose a reason for hiding this comment

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

There was a branch in Request.ctor that wasn't being hit by tests, this test case hits it

catch (Exception ex)
{
Log.RequestParsingError(Logger, ex);
Server.SendError(_requestId.Value, StatusCodes.Status400BadRequest, authChallenges: null);
Copy link
Member

Choose a reason for hiding this comment

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

It's not immediately obvious that this is a safe place to call SendError. What does it do? Is it synchronous? Does it schedule something? It doesn't depend on anything established by InitializeFeatures?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a synchronous call, only state it needs from InitializeFeature is the request ID which we pass in. Would you like some sort of comment here mentioning it's a synchronous call to native code?

@BrennanConroy
Copy link
Member Author

/backport to release/8.0

Copy link
Contributor

Copy link
Contributor

@BrennanConroy backporting to release/8.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Http.Sys: Clean up Request parsing errors
Using index info to reconstruct a base tree...
M	src/Servers/HttpSys/src/RequestProcessing/Request.cs
M	src/Servers/HttpSys/src/RequestProcessing/RequestContext.cs
M	src/Servers/HttpSys/test/FunctionalTests/Listener/RequestTests.cs
M	src/Servers/HttpSys/test/FunctionalTests/RequestTests.cs
M	src/Servers/HttpSys/test/FunctionalTests/ResponseCachingTests.cs
M	src/Servers/HttpSys/test/FunctionalTests/ResponseSendFileTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Servers/HttpSys/test/FunctionalTests/ResponseSendFileTests.cs
Auto-merging src/Servers/HttpSys/test/FunctionalTests/ResponseCachingTests.cs
Auto-merging src/Servers/HttpSys/test/FunctionalTests/RequestTests.cs
Auto-merging src/Servers/HttpSys/test/FunctionalTests/Listener/RequestTests.cs
CONFLICT (content): Merge conflict in src/Servers/HttpSys/test/FunctionalTests/Listener/RequestTests.cs
Auto-merging src/Servers/HttpSys/src/RequestProcessing/RequestContext.cs
CONFLICT (content): Merge conflict in src/Servers/HttpSys/src/RequestProcessing/RequestContext.cs
Auto-merging src/Servers/HttpSys/src/RequestProcessing/Request.cs
CONFLICT (content): Merge conflict in src/Servers/HttpSys/src/RequestProcessing/Request.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Http.Sys: Clean up Request parsing errors
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

Copy link
Contributor

@BrennanConroy an error occurred while backporting to release/8.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@wtgodbe
Copy link
Member

wtgodbe commented Sep 12, 2024

@BrennanConroy ready to merge?

@wtgodbe wtgodbe merged commit 37dd88b into release/9.0 Sep 12, 2024
25 checks passed
@wtgodbe wtgodbe deleted the brecon/httpsyscleanup2 branch September 12, 2024 16:51
@dotnet-policy-service dotnet-policy-service bot removed this from the 9.0-rc2 milestone Sep 12, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-rc2 milestone Sep 12, 2024
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 Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants