Skip to content

[release/6.0] Throw for bad requests intended for minimal route handlers in development #36072

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

Merged
merged 2 commits into from
Sep 2, 2021

Conversation

halter73
Copy link
Member

@halter73 halter73 commented Sep 2, 2021

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.

image

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.

@halter73 halter73 changed the base branch from main to release/6.0 September 2, 2021 00:13
@halter73 halter73 removed request for a team, Pilchie, dougbu and wtgodbe September 2, 2021 00:13
@halter73
Copy link
Member Author

halter73 commented Sep 2, 2021

Sorry for the code review spam. I accidently targeted main as the base branch initially.

@halter73 halter73 force-pushed the halter73/35858-backport branch from 0c4e1da to 7687514 Compare September 2, 2021 03:12
@Pilchie Pilchie added the old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Sep 2, 2021
- Preserve BadHttpRequestException.StatusCode in DeveloperExceptionPageMiddleware
- Improve RequiredParameterNotProvided log
- Use TypeNameHelper in RequestDelegateFactory
@halter73 halter73 force-pushed the halter73/35858-backport branch from 7687514 to efea9d3 Compare September 2, 2021 20:10
@halter73
Copy link
Member Author

halter73 commented Sep 2, 2021

@dotnet/aspnet-build Can someone please merge this? Thanks!

@wtgodbe wtgodbe merged commit e8c5c8a into release/6.0 Sep 2, 2021
@wtgodbe wtgodbe deleted the halter73/35858-backport branch September 2, 2021 22:54
@ghost ghost added this to the 6.0-rc2 milestone Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants