-
-
Notifications
You must be signed in to change notification settings - Fork 162
Description
Greetings everyone, and thank you for your incredible work.
I'm trying for the first time to use the feature of Atomic Operations and though I'm certain I have done everything right, I keep getting bogus errors.
I have implemented several CRUD actions for my resources that work well for the past year.
Now I'm trying to find out how to perform Bulk actions, starting with the simplest scenario, a single "add" operation.
I've changed the content type to application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"
I've created an sealed OperationsController that derives from JsonApiOperationsController and I have overridden the method PostOperationsAsync just to be able to debug (I know it is not necessary to override it).
I have a resource of type "ProductPricelistItem" and the following is my pretty simple payload:
{
"atomic:operations": [
{
"op": "add",
"data": {
"type": "ProductPricelistItem",
"attributes": {
"priceType": "CurrencyAmount"
}
}
}
]
}
Upon executing POST I get the error:
500
"ValidationVisitor exceeded the maximum configured validation depth '32' when validating property 'PublicName' on type 'JsonApiDotNetCore.Resources.Annotations.ResourceFieldAttribute'. This may indicate a very deep or infinitely recursive object graph. Consider modifying 'MvcOptions.MaxValidationDepth' or suppressing validation on the model type."
After following the messages advice (and as suggested elsewhere) I go to my services configuration and add
services.AddMvc().AddMvcOptions(options => { options.MaxValidationDepth = 99999; });
That seems to eliminate the particular problem and I see the debugger continues to PostOperationsAsync.
But there are two problems.
- The "[FromBody] IList operations" parameter comes as 'null'
- All my other already established and working endpoints, stop to work and I get a huge error

I also tried adding the Attribute [ValidateNever] at my Resource but that doesn't seem to do anything.
Also, as suggested elsewhere, I tried adding options.MaxModelValidationErrors = 999999; at my parameters but nothing.
I've tried several tweaks in my Payload, hoping it may have something to do with it but upon trying another scenario, where I omit the setup of MaxValidationDepth and I put a deliberate error in "attributes", writing the "priceType" as "priceTypeQQQ", the parser informs me the following, which is correct which makes me think that my original Payload is correct because I don't get that error with "priceType", only the "ValidationVisitor" error. Upon setting the MaxValidationDepth I don't get the parsing error but anyway the operations parameter always comes as 'null'
Am I missing something?
What could be the cause of the 'null' in operations parameter and how can I overcome the ValidatorVisitor problem and still keep my other endpoints working?
Please advise
VERSIONS USED
- JsonApiDotNetCore version: 5.5.1
- ASP.NET Core version: 8.0.6
- Entity Framework Core version: 8.0.4
- Database provider: SQL Server 14.0.2052.1


