-
Notifications
You must be signed in to change notification settings - Fork 10.3k
NewtonsoftJsonInputFormatter does not threat FormatException as MalformedInputException #14504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This looks like a good 3.1 candidate. @pranavkm - do you know if this is a regression? |
@pranavkm if this is not a regression, please move to 5.0. |
@ig-sinicyn I can't seem to reproduce your issue. The error is correctly reported as a model state error. Could you share a minimal repro? |
Feel free to reopen if you're able to share a minimal app that reproduces the error. |
@pranavkm sorry for delay. I'll add a repro today. |
Well, the case was services.AddNewtonsoftJson(o =>
{
o.SerializerSettings.Converters = new List<JsonConverter>
{
new IsoDateTimeConverter()
};
}); Repro: ReproJsonContent.zip Technically it's Newtonsoft.Json issue caused by using a legacy converter. |
@pranavkm Github does not allow to reopen issues that was closed by repo collaborator, can you reopen it for me? |
…state errors In SystemTextJsonInputFormatter and NewtonsoftJsonInputFormatter, suppress FormatExceptions and OverflowExceptions and instead report them as model state errors. This makes the behavior more consistent between these formatters, model binders, and the XML formatters Fixes #14504
…state errors (#15035) In SystemTextJsonInputFormatter and NewtonsoftJsonInputFormatter, suppress FormatExceptions and OverflowExceptions and instead report them as model state errors. This makes the behavior more consistent between these formatters, model binders, and the XML formatters Fixes #14504
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
NewtonsoftJsonInputFormatter does not handle malformed input at least for DateTime fields.
So, malformed request results in unhandled exception and http 500 response.
To Reproduce
Net core 3, controller:
setup:
UPD, the
does not help.
request:
Actual behavior
http 500, exception stack:
Expected behavior
Invalid input should be handled by
InvalidModelStateResponseFactory
call (http 400, by default).Additional context
As a hack the formatter may be replaced with any derived class, explanation:
The text was updated successfully, but these errors were encountered: