Skip to content

Fix LocalStore.GetChunk dropping read errors#363

Merged
folbricht merged 1 commit into
masterfrom
fix-localstore-read-errors
Jul 5, 2026
Merged

Fix LocalStore.GetChunk dropping read errors#363
folbricht merged 1 commit into
masterfrom
fix-localstore-read-errors

Conversation

@folbricht

Copy link
Copy Markdown
Owner

LocalStore.GetChunk() only checked the error from os.ReadFile with os.IsNotExist(). Any other read failure — permission problems, I/O errors, truncated reads — was silently ignored and the nil or partial buffer handed to NewChunkFromStorage():

  • With verification enabled, the caller saw a misleading ChunkInvalid instead of the real error (and a RepairableCache would then treat it as missing and re-fetch, hiding e.g. a permission problem indefinitely).
  • With SkipVerify set (--skip-verify, or the pull command), the store returned a chunk holding partial data with no error at all.

Return the underlying error instead. The new test uses a directory in place of the chunk file to trigger a non-IsNotExist read error on all platforms; it fails against the previous code (returned a bogus chunk with nil error under SkipVerify).

Any error from os.ReadFile other than "file does not exist" - permission
problems, I/O errors, truncated reads - was silently ignored and the
nil or partial buffer handed to NewChunkFromStorage. With verification
enabled the caller saw a misleading ChunkInvalid instead of the real
error, and with SkipVerify set the store returned a chunk holding
partial data with no error at all.

Return the underlying error instead.
@folbricht folbricht merged commit 39a25e5 into master Jul 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant