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

Change default of DeserializationFeature.FAIL_ON_TRAILING_TOKENS to true for 3.0 #3406

Closed
yawkat opened this issue Feb 28, 2022 · 8 comments
Closed
Labels
3.0 Issue planned for initial 3.0 release
Milestone

Comments

@yawkat
Copy link
Member

yawkat commented Feb 28, 2022

imo it is better to fail by default here. If you're parsing line-delimited json, you'll notice immediately if you forget to turn off FAIL_ON_TRAILING_TOKENS. However in the other direction, if it was off by default and you forget to turn it on, you probably would never notice (few people test for failures), which could also open up the door to parsing differential vulnerabilities in an application.

See discussion on #3400

@yawkat yawkat added the to-evaluate Issue that has been received but not yet evaluated label Feb 28, 2022
@cowtowncoder cowtowncoder added 3.x Issues to be only tackled for Jackson 3.x, not 2.x and removed to-evaluate Issue that has been received but not yet evaluated labels Apr 21, 2022
@cowtowncoder cowtowncoder added 3.0 Issue planned for initial 3.0 release and removed 3.x Issues to be only tackled for Jackson 3.x, not 2.x labels Dec 1, 2024
@cowtowncoder
Copy link
Member

Have not yet decided but will include in "potentially for 3.0.0" list, will bring up on discussion (to be created).

@JooHyukKim
Copy link
Member

Though the rationale here makes sense (and the one from #3400), this seems to be have similar aspects to #493 about FAIL_ON_UNKNOWN_PROPERTIES feature.

So main opposing idea would be the Postel's Law saying...

"be conservative in what you do, be liberal in what you accept from others".

... at the moment I don't have strong opinion on either side yet. I wish we could invite over the same crowd from #493 for discussion 😅.

@cowtowncoder cowtowncoder changed the title Change default of FAIL_ON_TRAILING_TOKENS to true for 3.0 Change default of DeserializationFeature.FAIL_ON_TRAILING_TOKENS to true for 3.0 Dec 1, 2024
@cowtowncoder
Copy link
Member

cowtowncoder commented Dec 1, 2024

See discussion at FasterXML/jackson-future-ideas#74 wrt whether to make proposed change in 3.0.0.

@cowtowncoder
Copy link
Member

Proposal approved: can proceed with this change.

@cowtowncoder
Copy link
Member

Ok: trying to work through PR shows a few issues -- initially about 30 unit test failures, of which only 2 are for specific checking of configuration settings.

I have been able to resolve about 2/3 of them, leaving (as of now) 11 failures. Will keep on working through them to get closer to 0.

However: I am finding potential concerns about this change... will see how remaining failures look like, and will outline my concerns if some remain.
It is possible we'd need to consider only verifying trailing tokens for case where readValue() is called with input source other than JsonParser, since passing JsonParser may suggest desire for partial reads.
But I'll look into this bit more first.

cowtowncoder added a commit that referenced this issue Jan 15, 2025
@cowtowncoder
Copy link
Member

Ok. So, all remaining 11 failures are actually weird, but due to same underlying issue: use of External Type Id leading to:

Unexpected close marker '}': expected ']'

failures. This must be due to the way JsonTypeInfo.Include.EXTERNAL_PROPERTY is internally handled and not due to actual parsing.

This suggests problem unrelated to DeserializationFeature.FAIL_ON_TRAILING_TOKENS, actually, which is good. But unfortunately I am at loss as to how to actually resolve it at this point.
So without somehow resolving this issue, change to defaults cannot proceed because:

  1. Unit test must pass, and in this case changing defaults is wrong (hiding true problem). But more importantly...
  2. ... some users would probably hit this problem with default change (otherwise they would only do so if explicitly enabling feature).

So will need to put this on hold for now, probably. :-/

cowtowncoder added a commit that referenced this issue Jan 30, 2025
cowtowncoder added a commit that referenced this issue Jan 30, 2025
cowtowncoder added a commit that referenced this issue Jan 30, 2025
@cowtowncoder cowtowncoder added this to the 3.0.0 milestone Jan 30, 2025
@cowtowncoder
Copy link
Member

Turns out issue was not as serious as I thought: odd error message is a flaw to fix via:

FasterXML/jackson-core#1394

but was triggered by erroneous JSON in test.

Now merged: will see how many downstream test fails we get :)

@cowtowncoder
Copy link
Member

Wow. This change has been great for teasing out various bigger and smaller flaws on both core and format modules (last fix was for Protobuf backend that had regression in 3.0.0, only caught by trailing tokens check). Still got one remaining XML issue to eventually fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 Issue planned for initial 3.0 release
Projects
None yet
Development

No branches or pull requests

3 participants