Skip to content

Adopt ProblemHttpResult pattern for ProblemDetailsService in TypedResults#65114

Closed
Copilot wants to merge 2 commits intofeature/typed-results-problemdetails-servicefrom
copilot/sub-pr-64967-again
Closed

Adopt ProblemHttpResult pattern for ProblemDetailsService in TypedResults#65114
Copilot wants to merge 2 commits intofeature/typed-results-problemdetails-servicefrom
copilot/sub-pr-64967-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 18, 2026

Adopt ProblemHttpResult pattern for ProblemDetailsService in TypedResults

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Standardizes ProblemDetailsService handling across TypedResults to match ProblemHttpResult pattern.

Description

The TypedResults classes (BadRequest<T>, InternalServerError<T>, Conflict<T>, UnprocessableEntity<T>) used an inconsistent pattern for handling IProblemDetailsService compared to ProblemHttpResult.

Changed pattern from:

var problemDetailsService = httpContext.RequestServices.GetService<IProblemDetailsService>();
if (problemDetailsService is not null &&
    await problemDetailsService.TryWriteAsync(...))
{
    return;
}

await HttpResultsHelper.WriteResultAsJsonAsync(...);

To:

var problemDetailsService = httpContext.RequestServices.GetService<IProblemDetailsService>();
if (problemDetailsService is null || !await problemDetailsService.TryWriteAsync(...))
{
    await HttpResultsHelper.WriteResultAsJsonAsync(...);
}

This aligns with the established pattern in ProblemHttpResult.cs and eliminates the early return, making the fallback logic explicit.

Files Changed

  • InternalServerErrorOfT.cs
  • BadRequestOfT.cs
  • ConflictOfT.cs
  • UnprocessableEntityOfT.cs

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: mikekistler <85643503+mikekistler@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on ProblemDetailsService implementation Adopt ProblemHttpResult pattern for ProblemDetailsService in TypedResults Jan 18, 2026
Copilot AI requested a review from mikekistler January 18, 2026 17:37
@mikekistler
Copy link
Copy Markdown
Contributor

Thanks @copilot, but I'll just make this change myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants