Skip to content
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

Fix Coercion fail message around Array and Object #3962

Conversation

JooHyukKim
Copy link
Member

resolves #3924

@JooHyukKim JooHyukKim marked this pull request as ready for review June 1, 2023 03:21
@cowtowncoder
Copy link
Member

Ok. So, after reading, re-reading things, I am not sure this is quite the way to fix the problem.

The thing is that aside from "Scalar from Object" work-around needed for XML backend (failing for others including JSON), there is no coercion we would actually consider: we are just failing in general by calling ctxt.handleUnexpectedToken() -- but there we are passing getValueType(ctxt) which is wrong.

So I think test change is good, but the fix should be much simpler: I'll add a note to point it.

@cowtowncoder
Copy link
Member

Ok so I can't attach code review comment in place, so this line:

return (String) ctxt.handleUnexpectedToken(getValueType(ctxt), p);

needs to be changed to, I think:

return (String) ctxt.handleUnexpectedToken(rawTargetType, p);

and that's the proper fix here.

Plus change to call ctxt.extractScalarFromObject(...) to also pass rawTargetType, not _valueClass.

@cowtowncoder cowtowncoder merged commit 404d64b into FasterXML:2.16 Jun 5, 2023
@cowtowncoder cowtowncoder added this to the 2.16.0 milestone Jun 5, 2023
@cowtowncoder cowtowncoder changed the title Fix Coercion fail message around Array and Object. Fix Coercion fail message around Array and Object Jun 5, 2023
@JooHyukKim JooHyukKim deleted the 3924-Incorrect-target-type-when-disabling-coercion branch June 5, 2023 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect target type when disabling coercion, trying to deserialize String from Array/Object
2 participants