Skip to content

fix(loki.source.file): Update tail_from_end to properly handle file encoding#5429

Merged
kalleep merged 9 commits intomainfrom
kalleep/fix-tail-from-end
Feb 4, 2026
Merged

fix(loki.source.file): Update tail_from_end to properly handle file encoding#5429
kalleep merged 9 commits intomainfrom
kalleep/fix-tail-from-end

Conversation

@kalleep
Copy link
Contributor

@kalleep kalleep commented Feb 4, 2026

Brief description of Pull Request

When tail_from_end = true we no longer produce invalid line on first read when reading UTF-16LE encoded files.

Pull Request Details

The issue was that getLastLinePosition did not take file encoding into account. I moved the logic into tail.reader so that we can perform this kind of operation with either configured or detected encoding.

Issue(s) fixed by this Pull Request

Fixes: #5423

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

@kalleep kalleep requested a review from a team as a code owner February 4, 2026 10:18
@kalleep kalleep changed the title fix(loki.source.file): tail_from_end now properly handle file encoding fix(loki.source.file): Update tail_from_end to properly handle file encoding Feb 4, 2026
@kalleep kalleep merged commit 807ff00 into main Feb 4, 2026
47 checks passed
@kalleep kalleep deleted the kalleep/fix-tail-from-end branch February 4, 2026 14:05
@kalleep kalleep added the backport/v1.13 Backport to release/v1.13 label Feb 4, 2026
grafana-alloybot bot pushed a commit that referenced this pull request Feb 4, 2026
… encoding (#5429)

### Brief description of Pull Request
When `tail_from_end = true` we no longer produce invalid line on first
read when reading `UTF-16LE` encoded files.

### Pull Request Details
The issue was that `getLastLinePosition` did not take file encoding into
account. I moved the logic into `tail.reader` so that we can perform
this kind of operation with either configured or detected encoding.

### Issue(s) fixed by this Pull Request

Fixes: #5423

### Notes to the Reviewer

<!-- Add any relevant notes for the reviewers and testers of this PR.
-->

### PR Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to
[x]. -->

- [ ] Documentation added
- [x] Tests updated
- [ ] Config converters updated

(cherry picked from commit 807ff00)
kalleep added a commit that referenced this pull request Feb 4, 2026
… encoding [backport] (#5436)

## Backport of #5429

This PR backports #5429 to release/v1.13.

### Original PR Author
@kalleep

### Description
### Brief description of Pull Request
When `tail_from_end = true` we no longer produce invalid line on first
read when reading `UTF-16LE` encoded files.

### Pull Request Details
The issue was that `getLastLinePosition` did not take file encoding into
account. I moved the logic into `tail.reader` so that we can perform
this kind of operation with either configured or detected encoding.

### Issue(s) fixed by this Pull Request

Fixes: #5423

### Notes to the Reviewer

<!-- Add any relevant notes for the reviewers and testers of this PR.
-->

### PR Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to
[x]. -->

- [ ] Documentation added
- [x] Tests updated
- [ ] Config converters updated


---
*This backport was created automatically.*

Co-authored-by: Karl Persson <23356117+kalleep@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/v1.13 Backport to release/v1.13 frozen-due-to-age

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: tail_from_end can produces invalid first line

2 participants