question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Try adding support for `JsonNode` and full resolution of Object Ids, without need for `@JsonIdentityInfo`

See original GitHub issue

(note: lots of background, and follow-up for #98)

So: handling of YAML Anchors, References, is problematic since: JSON has no directly equivalent notion. And although similar logical concept has been added by Jackson – Object Id, via @JsonIdentityInfo – it is both bit awkward to use and limited in scope (i.e. not handling all cases).

But it might be possible to implement full, no-annotation style resolution just for “Tree Model” (that is, JsonNode). Since there is already

JsonParser.canReadObjectId()

to indicate if format is capable of expressing Object Ids natively (returning true for YAML), it might be possible to combine this with another setting that essentially indicates that automatic resolution should be used. I am not 100% sure if this is indeed doable, especially with 2.x, but I think it is worth exploring. And with Jackson 3.0 it should be even more likely to be doable.

So. If and when I have time to investigate this, I’d like to see if this can be made.

The obvious corollary, then, would be that much of YAML processing would first use readTree() (and equivalents) to resolve all references, and then either use that or use mapper.treeToValue() to get to actual POJOs, ones that need not handle anchors/refs at all.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Jan 21, 2020

Ah. Yes, there’s that too, good point (I am familiar with that problem from xml context).

It would only be applicable if Object Id was resolved by expanding contents; my original thinking was (… I think) to retain actual identity and use loops. This would not expand size of content, although code using such structures (possibly cyclic graphs, if YAML [and more specifically, SnakeYAML] allows this – I am not sure YAML does actually) would need to be aware that to avoid problems at level.

So ability to prevent expansion probably makes sense no matter what.

0reactions
bentmanncommented, Jan 20, 2020

It’s not just about resolving external references but generally defending against expansion bombs, cf. https://en.wikipedia.org/wiki/Billion_laughs_attack#Variations

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson YAML: support for anchors and references
First, Jackson actually does support YAML anchors and references, at least to degree they work with how Jackson supports Object Id ...
Read more >
JsonIdentityInfo (Jackson-annotations 2.7.0 API) - FasterXML
In practice this is done by serializing the first instance as full object and object identity, and other references to the object as...
Read more >
Red Hat JBoss Enterprise Application Platform 7.1.0.Beta1
Helper method we need to do necessary conversion from whatever native object id type is, into declared type that Jackson internals expect.
Read more >
Index (jackson-databind 2.9.0 API)
Method called to add a full Object array as a chunk buffered within this buffer, ... We need a custom deserializer both because...
Read more >
TourDeJackson-ForgottenFeatures - Google Slides
Resolution mechanism (type name to/from class) 2. Object Identity (@JsonIdentityInfo) a. Id generators (sequence, UUID, from-property) b. Property name (no ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found