Open TjeuKayim opened 3 years ago
Tagging subscribers to this area: @ajcvickers See info in area-owners.md if you want to be subscribed.
Author: | TjeuKayim |
---|---|
Assignees: | - |
Labels: | `area-System.ComponentModel.DataAnnotations`, `untriaged` |
Milestone: | - |
This happens because Range(0, 7)
is using the Range(int, int)
constructor. As such, it's trying to convert the supplied uint value of 4,000,000,000 to an int, which results in an overflow. I don't know whether that's the desired behavior for RangeValidator.IsValid, but presumably it should just have another catch for OverflowException at:
https://github.com/dotnet/runtime/blob/5761dd49339911241209c1ffd61105a94edb6df1/src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/RangeAttribute.cs#L124-L135
Regardless, as a workaround you should be able to use Range(typeof(uint), "0", "7")
instead.
Thanks for the explanation!
Describe the bug
The validation for a
uint
query parameter withRangeAttribute
can causeSystem.OverflowException
instead of responding with status code 400 Bad Request.To Reproduce
Create a new ASP.NET 5 Web API project, add this method to the controller:
Exceptions
Further technical details
dotnet --info