Skip to content

Return ProblemDetails with error detail on every failure arm and compose ProblemDetails customization#326

Merged
Vulthil merged 1 commit into
mainfrom
claude/api-result-http-mapping-1e72f2
Jul 19, 2026
Merged

Return ProblemDetails with error detail on every failure arm and compose ProblemDetails customization#326
Vulthil merged 1 commit into
mainfrom
claude/api-result-http-mapping-1e72f2

Conversation

@Vulthil

@Vulthil Vulthil commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • ProblemHttpResult/ObjectResult now carry the error's code+description on every failure arm on both
    public paths (typed IResult via ToIResult/CustomResults.Problem, and MVC via ToActionResult) — NotFound
    and Conflict no longer return bare, detail-less responses.
  • ErrorType.Problem now maps to HTTP 400 (client-addressable) instead of being lumped into the 500 default
    arm, on both paths.
  • AddProblemDetailsHandling now composes the package's requestId/traceId enrichment with any
    consumer-supplied CustomizeProblemDetails via PostConfigure, instead of one silently overwriting the other.
  • The OpenAPI 500-response transformer now always merges (preserving an existing response's Description
    instead of discarding it on net10 with nullable Content) and attaches a ProblemDetails schema to the
    problem+json media type, on both net9 and net10.
  • MVC ToActionResult no longer populates ModelState for non-validation errors that never read it.
  • BaseController.Logger is now cached after first resolution instead of re-resolving ILoggerFactory +
    creating a logger on every access.
  • AddEndpoints skips open-generic IEndpoint implementors (previously registered them, which blew up later
    at resolution); MapEndpoints resolves endpoints from a dedicated scope instead of the root provider.
  • Aligned ArgumentNullException.ThrowIfNull guards across the public extension methods in these files.

Observable HTTP payload changes

  • 404/409 responses on both public paths now return an RFC 7807 body instead of an empty body.
  • Failures with ErrorType.Problem now return HTTP 400 instead of 500.
  • The generated OpenAPI document's synthesized 500 response now has a real ProblemDetails schema; an
    existing 500 response's Description is preserved when merged instead of being replaced.

Verification

  • Full solution build: clean, 0 warnings, 0 errors.
  • New Vulthil.SharedKernel.Api.Tests project (31 tests): one test per ErrorType arm on both paths,
    the CustomizeProblemDetails composition test, transformer merge/schema on both net9.0/net10.0, and
    endpoint-registration hardening. All 31 pass on the fix; 21 of 31 fail against unfixed main (verified by
    stashing the src changes and re-running), confirming each is load-bearing.
  • WebApi sample's own test suite (Testcontainers-backed): 8/8 pass — sample still boots, happy path unaffected.
  • Manually exercised a live 404 through the running sample and confirmed the new RFC 7807 payload shape.
  • PublicAPI.Shipped.txt/PublicAPI.Unshipped.txt untouched — no public signature changes.
  • Known follow-up (out of scope, owned by the parallel Results-semantics session):
    docs/articles/result-pattern.md's mapping table still says Problem → 500 and needs updating to 400.

Backport to v1.0: no — observable HTTP payload changes are minor-appropriate; ships in 1.1.0.

@claude

claude Bot commented Jul 19, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@Vulthil
Vulthil merged commit 0e136d6 into main Jul 19, 2026
6 checks passed
@Vulthil
Vulthil deleted the claude/api-result-http-mapping-1e72f2 branch July 19, 2026 18:24
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.

1 participant