Properly support different `FromBody.AllowEmpty` settings
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
The `FromBody` attribute currently accepts a boolean allowEmpty value that allows the developer to determine whether or not the route will accept an empty body as part of the request.
The attribute currently assumes that both `EmptyBodyBehavior.Default` and `EmptyBodyBehavior.Disallow` map to `allowEmpty = false` which is problematic when we want to discern scenarios where a developer explicitly set the `allowEmpty` parameter vs scenarios where we are using the implied value.
We'll need to update the codepath to discern when a user set the `AllowEmpty` attribute to support overriding the optionality configuration that was inferred from the code.
See https://github.com/dotnet/aspnetcore/pull/34505#discussion_r673361923 for more info.
Contributor guide
Research direction
Start with the FromBody attribute and the request-body optionality codepath described in the issue, then read the linked pull-request discussion for the intended distinction. Done means explicitly supplied AllowEmpty values can be distinguished from implied defaults, so they can override optionality inferred from the code while preserving Default and Disallow behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100