POST Action with DateTime in Model causes an not handlable exception which is never passed to client
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Assemblies affected
ASP.NET Core OData 8.x
Describe the bug
When I create a Post Action in an OdataController, the conversion of DateTime in it produces an internal OdataException, which cannot be catched.
Reproduce steps
- Create a OdataController with a POST Action
- Create a Model with a DateTime Field in it.
- Call the endpoint with the DateTime Field passed as a string in format YYYY-MM-ddThh:mm:ss.
- An exception is found when putting a debug in the action (in Rider it is stored in a $exception)
Data Model
public class WeatherForecast
{
public int Id {get; set;}
public DateTime? Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
Expected behavior
The error is passed to the client automatic or can be catched with UseExceptionHandler().
Screenshots
If applicable, add screenshots to help explain your problem.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the POST action in an ASP.NET Core OData 8.x OdataController with the WeatherForecast model and its nullable DateTime field, using the YYYY-MM-ddThh:mm:ss payload described. Trace where the internal ODataException occurs before the action and how UseExceptionHandler receives it. Done means the error is automatically returned to the client or can be caught by UseExceptionHandler.
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