-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Backport/pr 42384 to release/7.0 preview7 #42741
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
brunolins16
merged 60 commits into
dotnet:main
from
brunolins16:backport/pr-42384-to-release/7.0-preview7
Jul 19, 2022
Merged
Backport/pr 42384 to release/7.0 preview7 #42741
brunolins16
merged 60 commits into
dotnet:main
from
brunolins16:backport/pr-42384-to-release/7.0-preview7
Jul 19, 2022
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
Co-authored-by: Brennan <[email protected]>
Co-authored-by: Stephen Halter <[email protected]>
BrennanConroy
approved these changes
Jul 15, 2022
|
Hi @brunolins16. 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. |
Member
Author
|
Approved via email. |
10 tasks
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
Servicing-approved
Shiproom has approved the issue
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 #42384 to release/7.0-preview4
/cc @brunolins16
Adding ProblemDetailsService
Adding a new
ProblemDetailsServiceresponsible for consistentProblem Detailsgeneration.Description
API Controllers have a mechanism to auto generated
Problem Details(https://datatracker.ietf.org/doc/html/rfc7807) for API ControllerActionResult. The mechanism is enabled by default for allAPI Controllers, however, it will only generates aProblem Detailspayload when theAPI Controller Actionis processed and produces aHTTP Status Code 400+and noResponse Body, that means, scenarios like - unhandled exceptions, routing issues - won't produce aProblem Detailspayload.Here is overview of when the mechanism will produce the payload:
❌ = Not generated
✅ = Automatically generated
Routing issues: ❌
Unhandled Exceptions: ❌
MVC
StatusCodeResult400 and up: ✅ (based onSuppressMapClientErrors)BadRequestResultandUnprocessableEntityResultareStatusCodeResultProblemDetailsis specified in the input)UnprocessableEntityObjectResult415 UnsupportedMediaType: ✅ (Unless when aConsumesAttributeis defined)406 NotAcceptable: ❌ (when happens in the output formatter)Minimal APIswon't generate aProblem Detailspayload as well.Here are some examples of reported issues by the community:
This API introduce a new service that is consumed by
Diagnostics Middlewaresto have theProblemDetailsgenerated, for all Status 400+ and also have a mechanism that allows devs or library authors (eg. API Versioning) generateProblemDetailsresponses when opted-in by the users.Sample Usage
Default options
Fixes #42212
Customer Impact
This issue has been reported for years, including a community
middlewareis available to try fix the gap in the framework. This change does not replace the community middleware totally, however, enable the core functionality in the framework.Regression?
Risk
This is a new API. The change to existing code is very small and non-impactful unless the new
AddProblemDetailsmethod is called.Verification
Packaging changes reviewed?