-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
JsonInputFromatter validation issue #4946
Comments
Thanks for contacting us, @ArtemAstashkin. |
More that input formatting intentionally doesn't fill the I suspect this would worsen performance slightly.
Please define "spends a lot of time". In any case, we would either need to abort input formatting early (which conflicts with your first concern) or make FYI 2.1.1 is rather old. The current patch version of Microsoft.AspNetCore.All and Microsoft.AspNetCore.App is 2.1.6. |
I think the limit does not matter. If it exists somebody who knows about it will be able to generate unexpected request and damage a service.
No, in my case it takes several hundreds of milliseconds to parse this request for the first time and several dozens for the next times. For example 300-500 ms and 30-60 ms which seems too much.
I'm sure it is not significant to get all errors. I'm sure the better (faster, and easiest) case - to break the validation on the first error, no to try to collect hundreds.
It does not depend on the version - all current versions are the same according to this behavior. |
@ArtemAstashkin you have said
Do you mean the reported errors are incomplete? Or, is this a reiteration of your complaint that input formatting does not stop after the first error is encountered? |
I mean that instead of BadRequest status we receive HttpStatusCode.Ok despite invalid model, without any validation errors. |
That's due to the code in your action: if (this.ModelState.IsValid)
{
return this.Ok();
} |
Yes, it is related to the realization. |
@ArtemAstashkin I see now that this issue is a duplicate of aspnet/Mvc#7992. That bug was fixed in ASP.NET Core 2.2.0 (with aspnet/Mvc@f2608c2ff4). Suggest upgrading your application to 2.2.1, the latest 2.2.x release. |
Is this a Bug or Feature request?:
Bug
Steps to reproduce (preferably a link to a GitHub repo with a repro project):
I've attached the repo to reproduce this issue https://github.com/ArtemAstashkin/JsonInputFormatterTest
The test will fail. But, if you change 621 to 199 it will pass.
Description of the problem:
The issue is related to the JsonInputFormatter which tries to mark validation errors as handled and validate all items in arrays and all properties in a model. But it take a lot of time. Moreover it has a limit of exceptions (200 as default). Eventually if somebody sends invalid model with 600 string.Empty (for example, 201 - enough) in array instead of integers, the formatter will spend a lot of time to parse it without any expected result - because it will fail after 200th error and return status OK instead of BadRequest.
It has 2 problems:
Version of
Microsoft.AspNetCore.Mvc
orMicrosoft.AspNetCore.App
orMicrosoft.AspNetCore.All
:2.1.1
The text was updated successfully, but these errors were encountered: