-
Notifications
You must be signed in to change notification settings - Fork 117
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
InstantDeserializer is not respecting leniency w.r.t. to numeric values #217
Comments
Are any |
Here's a test. The expectation is that it should throw a mapping exception. If the deserialize method of InstantDeserializer checked leniency and if not lenient, invoked _failForNotLenient for the case JsonTokenId.ID_NUMBER_INT, then this would behave as expected. (This applies to the ID_NUMBER_FLOAT case as well.) |
One note: while there has been some confusion, leniency/strictness is meant (as of Jackson 2.12) to control specific values for legal types -- like "February 30, 2021" (accepted if lenient; not if strict) -- but it is not meant to be used to control coercions going forward. It is possible that |
@wong-git referenced the
Expanding on @wong-git 's rule, what about this? |
Given that the default handling with 2.x is lenient, we could consider strict mode to prevent use of numbers. At the same time we should probably also then check for coercion config. In fact, I think the way forward would be to check, in case of number formats:
Change in logic to be only done for 2.13, not 2.12.x, given that this is behavioral change. |
Applicable coercion config setting: fail if indicated that should be done (I can help finding the logic) Found some good documentation on coercion config, and from there I see the associated commits, but if you can recommend the logic that would be fine of course. I think this use case (for _
_ |
Yes, coercion block should either be added to
Either way, allowed coercion settings must be verified by deserializer (implemented by them); and we have to figure out expected rules considering backwards compatibility. Gets bit complicated quite quickly. |
We annotated some constructor properties with @jsonformat(lenient = OptBoolean.FALSE) but found that the InstantDeserializer is not applying it when deserializing numeric values.
Expected _failForNotLenient(parser, context, JsonToken.VALUE_STRING) to be invoked for the numeric cases in InstantDeserialize#deserialize when not lenient.
(It looks like LocalDateDeserializer implementation is applying leniency in the case of an integer value as expected; InstantDeserializer should implement similarly.)
The text was updated successfully, but these errors were encountered: