DotExpandingXContentParser to expose the original token location#84970
DotExpandingXContentParser to expose the original token location#84970javanna merged 3 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/es-search (Team:Search) |
|
Hi @javanna, I've created a changelog YAML for you. |
There was a problem hiding this comment.
I meant to add a test to reproduce this issue when indexing a document, but I did not find an easy way to do so. It turns out that a lot of errors that we throw as MapperParsingException don't actually hold the xcontent location, and the ones that do are parse exception coming from jackson directly. For the latter, the token location is not aligned only while expanding start or end object, which makes it hard to recreate the situation where the wrong token location would get returned without my fix.
All this said, I came to reconsider how important this fix is. Maybe in practice nobody will ever notice...?
There was a problem hiding this comment.
Or maybe we should be including xcontent location in more parsing exceptions? It's a bit odd that we use the same exception type for parsing mappings and parsing documents as well.
|
run elasticsearch-ci/part-2 |
|
run elasticsearch-ci/bwc |
With elastic#79922 we have introduced a parser that expands dots in fields names on the fly, so that the expansion no longer needs to be handled by consumers. The token location exposed by such parser can be confusing to interpret: consumers are parsing the expanded version which requires jumping ahead reading tokens and exposing additional field names and start objects, while users have sent the unexpanded version and would like errors to refer to the original content. This commit adds a test for this scenario and tweaks the DotExpandingXContentParser to cache the token location before jumping ahead to expand dots in field names.
08bbbaf to
7474c98
Compare
💚 Backport successful
|
…stic#84970) With elastic#79922 we have introduced a parser that expands dots in fields names on the fly, so that the expansion no longer needs to be handled by consumers. The token location exposed by such parser can be confusing to interpret: consumers are parsing the expanded version which requires jumping ahead reading tokens and exposing additional field names and start objects, while users have sent the unexpanded version and would like errors to refer to the original content. This commit adds a test for this scenario and tweaks the DotExpandingXContentParser to cache the token location before jumping ahead to expand dots in field names.
) With #79922 we have introduced a parser that expands dots in fields names on the fly, so that the expansion no longer needs to be handled by consumers. The token location exposed by such parser can be confusing to interpret: consumers are parsing the expanded version which requires jumping ahead reading tokens and exposing additional field names and start objects, while users have sent the unexpanded version and would like errors to refer to the original content. This commit adds a test for this scenario and tweaks the DotExpandingXContentParser to cache the token location before jumping ahead to expand dots in field names.
With #79922 we have introduced a parser that expands dots in fields names on the fly, so that the expansion no longer needs to be handled by consumers.
The token location exposed by such parser can be confusing to interpret: consumers are parsing the expanded version which requires jumping ahead reading tokens and exposing additional field names and start objects, while users have sent the unexpanded version and would like errors to refer to the original content.
This commit adds a test for this scenario and tweaks the DotExpandingXContentParser to cache the token location before jumping ahead to expand dots in field names.