Skip to content

fix(jsonparser): Fix possible JSON log line corruption caused by json parser on query path (backport release-3.5.x) #18059

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

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

loki-gh-app[bot]
Copy link
Contributor

@loki-gh-app loki-gh-app bot commented Jun 11, 2025

Backport 153bbbc from #18056


What this PR does / why we need it:

This PR fixes two bugs in the json parser:

  1. 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 label app_name="foo".

  2. A bug that caused a wrong json path for the extracted field in the same conditions as 1, such as []string{"app", "name_extracted"} for app_name, instead of []string{"app", "name"}.

Which issue(s) this PR fixes:
Fixes #17267

…n` parser on query path (#18056)

This PR fixes two bugs in the json parser:

1. 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 label `app_name="foo"`.

2. A bug that caused a wrong json path for the extracted field in the same conditions as 1, such as `[]string{"app", "name_extracted"}` for `app_name`, instead of `[]string{"app", "name"}`.

Signed-off-by: Christian Haudum <[email protected]>
(cherry picked from commit 153bbbc)
@loki-gh-app loki-gh-app bot requested a review from a team as a code owner June 11, 2025 08:14
@loki-gh-app loki-gh-app bot added backport size/M type/bug Somehing is not working as expected labels Jun 11, 2025
@loki-gh-app loki-gh-app bot requested a review from chaudum June 11, 2025 08:14
@chaudum chaudum merged commit 546d456 into release-3.5.x Jun 11, 2025
71 checks passed
@chaudum chaudum deleted the backport-18056-to-release-3.5.x branch June 11, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport size/M type/bug Somehing is not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant