fix: propagate file close and gzip flush errors - #13
Merged
Conversation
SaveLogsAsync and CompressFile swallowed Close errors via bare defers, so a failed flush at close time (disk full, quota, network fs) reported an incomplete export or a truncated gzip archive as success. Close errors are now joined into the returned error; context cancellation is preserved through errors.Join so errors.Is(err, context.Canceled) in cmd/export.go still holds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q7Linc1WFpVVE4mEj6xmjG
martinconic
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
SaveLogsAsyncandCompressFileswallowedCloseerrors via baredefers:filestore.SaveLogsAsync: OS-buffered writes can surface a failure only when the file is flushed at close time (disk full, quota, network fs), so a failed close reported an incomplete export as success.gzipstore.CompressFile: worse —gzip.Writer.Closeflushes the remaining compressed bytes and writes the gzip footer, so a swallowed error there reported a truncated/corrupt.gziparchive as success.Close errors are now joined into the returned error via
errors.Join. Context cancellation is preserved:errors.Is(err, context.Canceled)incmd/export.gostill holds when both cancellation and a close failure occur.Flagged in the adversarial review of #8 (Finding 2); the bug predates that PR, hence a separate fix from
main.Changes
saveLogs/compresshelpers taking injectable writers so the close-error path is testable.Testing
go test -race ./...— all passmake lint— 0 issues🤖 Generated with Claude Code
https://claude.ai/code/session_01Q7Linc1WFpVVE4mEj6xmjG