Skip to content

Populate ProblemDetails.Status on error responses#254

Open
inghamc wants to merge 1 commit into
ardalis:mainfrom
inghamc:fix/populate-problemdetails-status
Open

Populate ProblemDetails.Status on error responses#254
inghamc wants to merge 1 commit into
ardalis:mainfrom
inghamc:fix/populate-problemdetails-status

Conversation

@inghamc

@inghamc inghamc commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #253.

ProblemDetails bodies were returned without Status set, so the body's status was null even though the HTTP status code was correct (and it was applied inconsistently — see #253 for the audit table). This populates it across both conversion paths:

  • Minimal API (MinimalApiResultExtensions): added Status to the 422 / 404 / 409 builders (the three that omitted it).
  • MVC (ActionResultExtensions): set ProblemDetails.Status from the resolved status code in ToActionResult, so it stays correct even when a consumer remaps status codes via ResultStatusMap, rather than hardcoding it in each builder.

Non-breaking — this only adds the status field to the response body; HTTP status codes are unchanged. Tested on net6.0 / net7.0 / net8.0.

🤖 Generated with Claude Code

ProblemDetails bodies for several statuses were returned without the
Status field set, so the JSON body's `status` was null even though the
HTTP status code was correct. Set it consistently across the Minimal API
and MVC conversion paths (RFC 7807 section 3.1).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

ProblemDetails.Status not populated on error responses

1 participant