Skip to content

Validation error responses ignore custom IProblemDetailsWriter #64486

@Clockwork-Muse

Description

@Clockwork-Muse

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm trying to change the written format of all ProblemDetails objects for unrelated reasons, but unfortunately I can't seem to get validation errors to use my custom IProblemDetailsWriter instance, it's completely ignored.

My instance is called for the simple set of exception handling (that would generate a 500) or for authentication errors that I've tested with so far, so it's configured and available.
I've tried removing all other writer implementationss at various points in my code and then configuring my instance, but no luck.

Expected Behavior

The provided custom IProblemDetailsWriter is used to write validation errors to the response.

Steps To Reproduce

Clone the provided repro

Start up the application

Make a web request like http://localhost:5285/some?id=750, observe the results do not match the generic "some response" configured in the repro, and setting breakpoints in the relevant methods does not result in trapped execution either.

Exceptions (if any)

None

.NET Version

8.0.415

Anything else?

.NET SDK:
 Version:           8.0.415
 Commit:            7bd5a8c970
 Workload version:  8.0.400-manifests.c414f008
 MSBuild version:   17.11.48+02bf66295

Runtime Environment:
 OS Name:     debian
 OS Version:  12
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.415/

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
  Version:      8.0.21
  Architecture: x64
  Commit:       362ab6669d

.NET SDKs installed:
  8.0.415 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.21 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.21 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Also repros in net10

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-problem-details

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions