Refuse to publish a staging file whose write failed - #59
Merged
Merged
Conversation
HashingStream appended each chunk to the digest before writing it, so a write that failed left bytes in the digest that never reached disk. StreamTee abandons a failed staging sink and keeps serving the client, and the download path published regardless, so when the failed write was the last one the short file still matched its oid and was published. Every later hit served the truncated object. HashingStream now digests only after the inner write succeeds and records that a write failed. StagingHandle exposes that as Faulted, and ObjectStore.PublishAsync discards a faulted handle before comparing digests, which covers the download and upload paths alike. Fixes #45 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016wsoxnwaqMuAzvkm2xnzYh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016wsoxnwaqMuAzvkm2xnzYh
|
This was referenced Sep 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.



Fixes #45
What was wrong
When the disk filled up on the last chunk of a download, the cache could publish a truncated object:
HashingStreamadded each chunk to the digest before writing it, so a chunk whose write failed still counted toward the digest.StreamTeeswallows the failure and keeps serving the client.If the failed write was the last one, the digest still matched the oid, so the short file was published and every later cache hit served it.
Change
HashingStreamadds a chunk to the digest only after the inner write succeeds, and records a failed write inFaulted.StagingHandle.Faultedexposes that flag.ObjectStore.PublishAsyncdiscards a faulted handle before comparing digests and logsDiscardedIncompleteObject(event 1009). Because the check is in the store, it covers both the download path and the upload path. The upload path already checkedSinkIsLive.Test
ObjectStoreTests.PublishAsync_StagingWriteFailedOnTheLastChunk_DoesNotPublishsends an object throughStreamTeeinto a staging stream whose final write throwsIOException. It covers two cases: an object that fits in a single chunk, and a two-chunk object where the second chunk fails. The test checks that the client gets every byte, that nothing is published, and that the staging file is removed.Assert.IsFalse(published). I checked this by stashing theGitLfsCache/changes and running the test.🤖 Generated with Claude Code
https://claude.ai/code/session_016wsoxnwaqMuAzvkm2xnzYh
Generated by Claude Code