-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Backport/pr 42384 to release/7.0 preview7 #42741
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 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 <brecon@microsoft.com>
Co-authored-by: Stephen Halter <halter73@gmail.com>
brunolins16
requested review from
a team,
Tratcher,
BrennanConroy,
javiercn,
halter73 and
Pilchie
as code owners
July 15, 2022 07:50
brunolins16
added
the
area-web-frameworks
*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
label
Jul 15, 2022
BrennanConroy
approved these changes
Jul 15, 2022
brunolins16
added
the
Servicing-consider
Shiproom approval is required for the issue
label
Jul 18, 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. |
brunolins16
added
Servicing-approved
Shiproom has approved the issue
and removed
Servicing-consider
Shiproom approval is required for the issue
labels
Jul 19, 2022
Approved via email. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-web-frameworks
*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
ProblemDetailsService
responsible for consistentProblem Details
generation.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 Details
payload when theAPI Controller Action
is processed and produces aHTTP Status Code 400+
and noResponse Body
, that means, scenarios like - unhandled exceptions, routing issues - won't produce aProblem Details
payload.Here is overview of when the mechanism will produce the payload:
❌ = Not generated
✅ = Automatically generated
Routing issues: ❌
Unhandled Exceptions: ❌
MVC
StatusCodeResult
400 and up: ✅ (based onSuppressMapClientErrors
)BadRequestResult
andUnprocessableEntityResult
areStatusCodeResult
ProblemDetails
is specified in the input)UnprocessableEntityObjectResult
415 UnsupportedMediaType
: ✅ (Unless when aConsumesAttribute
is defined)406 NotAcceptable
: ❌ (when happens in the output formatter)Minimal APIs
won't generate aProblem Details
payload as well.Here are some examples of reported issues by the community:
This API introduce a new service that is consumed by
Diagnostics Middlewares
to have theProblemDetails
generated, for all Status 400+ and also have a mechanism that allows devs or library authors (eg. API Versioning) generateProblemDetails
responses when opted-in by the users.Sample Usage
Default options
Fixes #42212
Customer Impact
This issue has been reported for years, including a community
middleware
is 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
AddProblemDetails
method is called.Verification
Packaging changes reviewed?