Skip to content

Conversation

@benclive
Copy link
Contributor

@benclive benclive commented Oct 31, 2025

What this PR does / why we need it:
Adds strict & keepEmpty for logfmt

  • This implements the flags for logfmt only. The JSON parser does not have the flags.
  • This also fixes an existing bug by ensuring that the new engine honors strict mode correctly

Which issue(s) this PR fixes:
Fixes https://github.com/grafana/loki-private/issues/2058

Checklist

  • Tests updated

@benclive benclive force-pushed the benclive/implement-strict-logfmt-parsing-again branch from 4a9e14b to d9a77fc Compare November 4, 2025 14:18
@benclive benclive marked this pull request as ready for review November 4, 2025 17:56
@benclive benclive requested a review from a team as a code owner November 4, 2025 17:56
@benclive benclive force-pushed the benclive/implement-strict-logfmt-parsing-again branch from 3130dd7 to 899d2ab Compare November 5, 2025 11:05
if cap(dst) >= 2 {
dst = dst[:2]
if cap(dst) >= 4 {
dst = dst[:4]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to clear out any references in dst[4:]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added clear(dst[4:]) to guard against this. Everything under index 4 is explicitly set to a new value.

@benclive benclive merged commit 01cab53 into main Nov 5, 2025
69 checks passed
@benclive benclive deleted the benclive/implement-strict-logfmt-parsing-again branch November 5, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants