-
Notifications
You must be signed in to change notification settings - Fork 155
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
400 JSON parse error when "constant.value=null" #883
Comments
That's a Twitter Finatra Jackson deserializer issue. It seems to require non-null values for non-optional fields. I need to investigate what can we do about it. |
Twitter Finatra Jackson ModulYes, Twitter Finatra Jackson requires non-null values for non-optional case class fields. It's also not really made to be configurable. There is an option to define a custom JsonDeserializer, but the null check happens after the deserialization. I don't think there is a way how to turn this off for just one field. As a workaround it is possible to set a default value to null. That would mean when there is null in input the default value will be used which is a null. The downside may be that this happens even when the json property for this field is missing in the input. Finatra seems to be useful only for enforcing the mandatory values. The json conversion seems to be working without it, but this should be tested better if we decide to stop using it. JacksonThere is very limited support for enforcing required fields in Jackson. They consider this a validation that should be handled separately. json4sSeems to support mandatory fields out of the box, but I don't know how hard is to turn this off for one specific field conclusionThe Best solution for now seems to be used default null value. If we want more grained control over this we will have to switch to a different Jackson parser or implement some Jackson Module ourselves. |
Adding a default value also makes this fiend optional in Swagger, and subsequently the field is treated as such in the client side code generated from the Swagger definitions. Being seemingly a small thing it could create unnecessary questions, confusion or a side effect in a long term perspective. I would prefer having a dirty hack on the server but keeping the API model correct. What if we fork Finatra and patch it? Perhaps introducing a custom annotation wouldn't be much of a problem there.. |
Ok I will fork the Finatra. One potential issue there is that they seem to make mandatory only case class fields. But since we use case classes everywhere in the API it's not a problem for us right now. |
When the execution plan contains a literal with
value: null
thenPOST /producer/execution-plans
returns 400.The issue is related to AbsaOSS/spline-spark-agent#200
The text was updated successfully, but these errors were encountered: