-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Throw for bad requests intended for minimal route handlers in development #36004
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
Conversation
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
Kahbazi
reviewed
Sep 1, 2021
2 things:
|
Tratcher
approved these changes
Sep 1, 2021
src/Middleware/Diagnostics/test/UnitTests/DeveloperExceptionPageMiddlewareTest.cs
Outdated
Show resolved
Hide resolved
Agreed, the dev exception page or the server will log at the error level when it catches. |
827b74d
to
75eccdc
Compare
davidfowl
approved these changes
Sep 1, 2021
davidfowl
reviewed
Sep 1, 2021
src/Http/Routing/src/DependencyInjection/RoutingServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
davidfowl
reviewed
Sep 1, 2021
src/Http/Routing/src/Builder/DelegateEndpointRouteBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1192214180 |
@halter73 backporting to release/6.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Improve RequiredParameterNotProvided log
Applying: Add and flow ThrowOnBadRequest
Applying: Use ThrowOnBadRequest in RequestDelegateFactory
Applying: Add more unit tests
Using index info to reconstruct a base tree...
M src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs
M src/Http/Routing/test/UnitTests/Builder/DelegateEndpointRouteBuilderExtensionsTest.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Http/Routing/test/UnitTests/Builder/DelegateEndpointRouteBuilderExtensionsTest.cs
CONFLICT (content): Merge conflict in src/Http/Routing/test/UnitTests/Builder/DelegateEndpointRouteBuilderExtensionsTest.cs
Auto-merging src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0004 Add more unit tests
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
5d22252
to
1141020
Compare
1141020
to
a36e57c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-middleware
Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares
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.
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.
Fixes #35858
Fixes #35857
Fixes #35954