-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-problem-details
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Currently, when writing passing ValidationProblemDetails/HttpValidationProblemDetails to default IProblemDetailsService/IProblemDetailsWriter implementations - ValidationProblemDetails/HttpValidationProblemDetails errors prop is being removed and type is overridden by base ProblemDetails.
public ValueTask WriteAsync(ProblemDetailsContext context)
{
if ((context.AdditionalMetadata?.GetMetadata<IApiBehaviorMetadata>() ?? context.HttpContext.GetEndpoint()?.Metadata.GetMetadata<IApiBehaviorMetadata>()) == null || _apiBehaviorOptions.SuppressMapClientErrors)
{
return ValueTask.CompletedTask;
}
ProblemDetails problemDetails = _problemDetailsFactory.CreateProblemDetails(context.HttpContext, context.ProblemDetails.Status ?? context.HttpContext.Response.StatusCode, context.ProblemDetails.Title, context.ProblemDetails.Type, context.ProblemDetails.Detail, context.ProblemDetails.Instance);
if (context.ProblemDetails?.Extensions != null)
{
foreach (KeyValuePair<string, object> extension in context.ProblemDetails.Extensions)
{
problemDetails.Extensions[extension.Key] = extension.Value;
}
}
OutputFormatterWriteContext context2 = new OutputFormatterWriteContext(context.HttpContext, _writerFactory.CreateWriter, typeof(ProblemDetails), problemDetails);
IOutputFormatter outputFormatter = _formatterSelector.SelectFormatter(context2, Array.Empty<IOutputFormatter>(), _problemContentTypes);
if (outputFormatter == null)
{
return ValueTask.CompletedTask;
}
return new ValueTask(outputFormatter.WriteAsync(context2));
}
Expected Behavior
IProblemDetailsService/IProblemDetailsWriter implementation should not remove ValidationProblemDetails/HttpValidationProblemDetails errors.
Steps To Reproduce
Create validation and pass it to default problem details service/writer:

Output after writing validation problem details with problem details service/writer:
{
"type": "https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"detail": "A validation problem occured.",
"traceId": "5e476057-e8c8-4994-b5f4-e5fcda6b8a8d",
"timestamp": "2025-08-20T17:32:37.4152604+00:00"
}
Exceptions (if any)
No response
.NET Version
9.0.304
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-problem-details