dotnet / dotnet/aspnetcore

Bad request / validation errors by the framework should state field names according to RFC 9457

Open
#57,714 3 comments 3 reactions 0 assignees View on GitHub
area-minimal area-mvc feature-problem-details
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

When a MVC or minimal API request is missing required fields the returned Problem Detail is just a generic error, e.g.:

```
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"$": [
"The input was not valid."
],
"request": [
"The request field is required."
]
},
"traceId": "00-03b1705be061cd08d86ed334c2f45eba-9e23a09ceaa7eb18-00"
}
```

Despite that multiple fields have been missing in this request the message only says that 'request field' is required. There is no information what fields are missing. Additionally, the errors elements don't follow RFC 9457 recommendation to use details and pointer members.

### Describe the solution you'd like

The framework should return for example:

```
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"detail": "The field is required.",
"pointer": "#/name"
},
{
"detail": "The field is required.",
"pointer": "#/address/street"
},
"traceId": "00-03b1705be061cd08d86ed334c2f45eba-9e23a09ceaa7eb18-00"
}
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.