-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Incorrect target type when disabling coercion, trying to deserialize String from Array/Object #3924
Comments
Sounds like there is missing handling indeed, thank you for reporting this @joca-bt! Unfortunately I don't think I have time to investigate this further right now; but I hope someone else could check it out; there should be enough information to dig into it. Change itself should probably go in 2.16 branch since it changes exception messages that are part of existing behavior (even if fixing sub-optimal message). |
I wrote a solution locally and the result seems reasonable. May I ask you to review the error messages below and see if they are the expected ones before I make a PR, @joca-bt @cowtowncoder ? Case :
Case :
Case :
|
@JooHyukKim That looks good to me; coercion failure happening at element level, not for Array/List. |
@cowtowncoder Thank you for the feedback! 🙏🏼🙏🏼 will make PR soon |
For me in particular the message is irrelevant, we care about the exception fields having the right type, since we rely on that and not the messages. |
@joca-bt Great point 👍🏻 I added assertion like below(or check the test I made on PR), does this prove to support your usecase? assertEquals(String.class, e.getTargetType()); |
When disabling coercions and providing a wrong type on an array element, the error message is specifying that we are trying to coerce the type of the array when it should mention we are trying to coerce the type of the element of the array. See the example below. This is another instance of #3690.
This is our test suite for JSON strict parsing which we have used to open many such issues in the past, in case you want to take inspiration for Jackson tests.
Test.zip
The text was updated successfully, but these errors were encountered: