Skip to content

DefaultProblemDetailsWriter doesn't pass cancellation token to WriteAsJsonAsync #66600

@Youssef1313

Description

@Youssef1313

public ValueTask WriteAsync(ProblemDetailsContext context)
{
var httpContext = context.HttpContext;
ProblemDetailsDefaults.Apply(context.ProblemDetails, httpContext.Response.StatusCode);
var traceId = Activity.Current?.Id ?? httpContext.TraceIdentifier;
var traceIdKeyName = _serializerOptions.PropertyNamingPolicy?.ConvertName("traceId") ?? "traceId";
context.ProblemDetails.Extensions[traceIdKeyName] = traceId;
_options.CustomizeProblemDetails?.Invoke(context);
var problemDetailsType = context.ProblemDetails.GetType();
return new ValueTask(httpContext.Response.WriteAsJsonAsync(
context.ProblemDetails,
_serializerOptions.GetTypeInfo(problemDetailsType),
contentType: "application/problem+json"));
}

HttpContext has RequestAborted property (of type CancellationToken). WriteAsJsonAsync accepts an optional cancellation token. Should we be passing the cancellation token in this code path?

Metadata

Metadata

Labels

area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcbugThis issue describes a behavior which is not expected - a bug.feature-problem-details

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions