Skip to content

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented Feb 2, 2022

Fire an event when allowing a bad request

This adds diagnostics for a prior fix so partners can determine when the client issues have been addressed.

Description

#39334 from Feb allowed a partner to opt into accepting a specific kind of bad request. They're working to address the issues with the remote client and aren't sure how long that will take. They've requested new event so they can add in their own logging to monitor the client's progress, detect if anyone else is encountering the issue, and decide if we need a long term fix added to 7.0.

Fixes #39756

Customer Impact

The customer is unable to tell if the prior mitigation is still required without disabling it and potentially breaking live customers.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

[Justify the selection above]

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@Tratcher Tratcher added this to the 6.0.x milestone Feb 2, 2022
@Tratcher Tratcher requested a review from halter73 February 2, 2022 22:12
@Tratcher Tratcher self-assigned this Feb 2, 2022
@ghost
Copy link

ghost commented Feb 2, 2022

Hi @Tratcher. If this is not a tell-mode PR, please make sure to follow the instructions laid out in the servicing process document.
Otherwise, please add tell-mode label.

@Tratcher Tratcher marked this pull request as ready for review February 2, 2022 22:22
@Tratcher Tratcher added the Servicing-consider Shiproom approval is required for the issue label Feb 2, 2022
@ghost
Copy link

ghost commented Feb 2, 2022

Hi @Tratcher. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.

To learn more about how to prepare a servicing PR click here.

Co-authored-by: Stephen Halter <halter73@gmail.com>
Comment on lines +1350 to +1358
_requestRejectedException = ex;

const string badRequestEventName = "Microsoft.AspNetCore.Server.Kestrel.BadRequest";
if (ServiceContext.DiagnosticSource?.IsEnabled(badRequestEventName) == true)
{
ServiceContext.DiagnosticSource.Write(badRequestEventName, this);
}

_requestRejectedException = null;
Copy link
Member

@JamesNK JamesNK Feb 3, 2022

Choose a reason for hiding this comment

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

What happens if an exception is thrown from DiagnosticSource.Write? Do we care that _requestRejectedException isn't set back to null?

tldr add try/finally?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that exception would cause the request to fail anyways, so _requestRejectedException wouldn't matter.

Copy link
Member

Choose a reason for hiding this comment

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

There are different paths that a request goes down on failure when this property is sent. e.g. writing a 400 response

@leecow leecow modified the milestones: 6.0.x, 6.0.3 Feb 3, 2022
// Normally this would have been rejected, but the developer opted into allowing the bad behavior.
public void ReportAllowedBadRequest(BadHttpRequestException ex)
{
Log.ConnectionBadRequest(ConnectionId, ex);
Copy link
Member

Choose a reason for hiding this comment

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

this is new logging that now occurs even without setting the appcontext switch?

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is only called when the appcontext switch is set. Compare to the SetBadRequestState method above that's called when the appcontext switch is not set. Both write the same log, but the new one avoids marking the request as failed/rejected.

@Pilchie Pilchie added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Feb 3, 2022
@Tratcher Tratcher merged commit 32fae69 into dotnet:release/6.0 Feb 3, 2022
@Tratcher Tratcher deleted the tratcher/release/6.0/kestrel-host branch February 3, 2022 18:40
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
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.

7 participants