[release/6.0] Throw for bad requests intended for minimal route handlers in development #36072
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.
Backport of #36004 to release/6.0
Customer Impact
Now instead of having to enable debug logging in development to see why a request is failing with a 400 response, you can easily see why the request is being rejected using the developer exception page or error logs.
This updates the DeveloperExceptionPageMiddleware to preserve the status code requested by the BadHttpRequestException instead of always responding with a 500. This way, the client can still get a 400 response in development but also get more error details.
This also updates the log messages (and the matching Exception messages) to use TypeNameHelper to produce friendlier parameter type names. And this includes the changes from #35580 which I'll close in favor of this.
Testing
This adds a lot of new unit and functional tests to cover this scenario. I also tested manually.
Risk
Low. This only affects bad requests that would be rejected either way. This also only impacts development environments to make debugging easier unless you opt-in.