fix(jsonparser): Fix possible JSON log line corruption caused by json
parser on query path (backport release-3.5.x)
#18059
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 153bbbc from #18056
What this PR does / why we need it:
This PR fixes two bugs in the json parser:
A bug that caused the original log line to be mutated by the json parser when the extracted field was a nested field and collided with an already existing label name, such as in line
{"app":{"id": 123, "name": "bar"}}
and labelapp_name="foo"
.A bug that caused a wrong json path for the extracted field in the same conditions as 1, such as
[]string{"app", "name_extracted"}
forapp_name
, instead of[]string{"app", "name"}
.Which issue(s) this PR fixes:
Fixes #17267