Skip to content

fix(loki.source.file): Close file if we cannot find encoding#5528

Merged
kalleep merged 1 commit intomainfrom
kalleep/fix-close-file
Feb 13, 2026
Merged

fix(loki.source.file): Close file if we cannot find encoding#5528
kalleep merged 1 commit intomainfrom
kalleep/fix-close-file

Conversation

@kalleep
Copy link
Contributor

@kalleep kalleep commented Feb 13, 2026

Pull Request Details

Noticed that we do not close file if we cannot get encoding. Review all other paths and we close file properly.

I really wish go had something like errdefer like zig does.

Issue(s) fixed by this Pull Request

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 13, 2026 08:27
@kalleep kalleep added the backport/v1.13 Backport to release/v1.13 label Feb 13, 2026
Copy link
Member

@blewis12 blewis12 left a comment

Choose a reason for hiding this comment

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

oh that's interesting, wondering if this could be applicable to the escalation you're looking at currently?

edit ah nevermind, I see the code changed was introduced more recently

@kalleep
Copy link
Contributor Author

kalleep commented Feb 13, 2026

edit ah nevermind, I see the code changed was introduced more recently

No but it got me to review the paths we are opening files

@kalleep kalleep merged commit 56bcb26 into main Feb 13, 2026
61 of 62 checks passed
@kalleep kalleep deleted the kalleep/fix-close-file branch February 13, 2026 09:54
@grafana-alloybot grafana-alloybot bot mentioned this pull request Feb 13, 2026
grafana-alloybot bot pushed a commit that referenced this pull request Feb 13, 2026
### Pull Request Details
Noticed that we do not close file if we cannot get encoding. Review all
other paths and we close file properly.

I really wish go had something like [errdefer like zig
does](https://ziglang.org/documentation/master/#errdefer).

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

<!--
Uncomment the following line and fill in an issue number if you want a
GitHub
  issue to be closed automatically when this PR gets merged.
-->

<!-- Fixes #issue_id -->

### 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
- [ ] Tests updated
- [ ] Config converters updated

(cherry picked from commit 56bcb26)
kalleep added a commit that referenced this pull request Feb 13, 2026
…t] (#5531)

## Backport of #5528

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

### Original PR Author
@kalleep

### Description
### Pull Request Details
Noticed that we do not close file if we cannot get encoding. Review all
other paths and we close file properly.

I really wish go had something like [errdefer like zig
does](https://ziglang.org/documentation/master/#errdefer).

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

<!--
Uncomment the following line and fill in an issue number if you want a
GitHub
  issue to be closed automatically when this PR gets merged.
-->

<!-- Fixes #issue_id -->

### 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
- [ ] Tests updated
- [ ] Config converters updated


---
*This backport was created automatically.*

Co-authored-by: Karl Persson <23356117+kalleep@users.noreply.github.com>
matt-gp pushed a commit to matt-gp/alloy that referenced this pull request Feb 13, 2026
…#5528)

### Pull Request Details
Noticed that we do not close file if we cannot get encoding. Review all
other paths and we close file properly.

I really wish go had something like [errdefer like zig
does](https://ziglang.org/documentation/master/#errdefer).

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

<!--
Uncomment the following line and fill in an issue number if you want a
GitHub
  issue to be closed automatically when this PR gets merged.
-->

<!-- Fixes #issue_id -->

### 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
- [ ] Tests updated
- [ ] Config converters updated
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 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.

2 participants