Treat a pack-less v2 fetch response as an error, not success#85
Open
Soph wants to merge 1 commit into
Open
Conversation
consumeV2FetchPack returned nil when the response ended (flush or EOF) without ever delivering a packfile section, so a truncated or empty response let a fetch report success having stored nothing. By the time control reaches here wants is non-empty (fetchToStoreV2/fetchPackV2 short-circuit the up-to-date case earlier), so the server owes us a packfile. Return io.ErrUnexpectedEOF on the no-packfile flush/EOF paths, matching the sibling openV2PackStream. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: a96014b75712
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.
Problem
consumeV2FetchPackreturnednilwhen the protocol-v2 fetch response ended — a bare flush or EOF — without ever delivering apackfilesection. So a truncated or pack-less response let a fetch report success having stored nothing. Its streaming siblingopenV2PackStreamcorrectly treats the same situation asio.ErrUnexpectedEOF.By the time control reaches either function,
wantsis non-empty (fetchToStoreV2/fetchPackV2both returngit.NoErrAlreadyUpToDateearly when there's nothing to fetch), so the server genuinely owes us a packfile section — a response without one is anomalous.Fix
Return
io.ErrUnexpectedEOFon the no-packfile flush/EOF paths inconsumeV2FetchPack, matchingopenV2PackStream. TheexpectPackfile(post-ready) branch keeps its existing, more specific message, and an empty-but-present pack still flows through the normalpackfilepath unchanged.Tests
TestStoreV2FetchPackRejectsResponseWithoutPackfile— a bare flush yieldsio.ErrUnexpectedEOF.TestStoreV2FetchPackRejectsTruncatedResponse— EOF before any packfile yieldsio.ErrUnexpectedEOF.These mirror the existing
openV2PackStreamrejection tests. Fullgo test ./...passes.🤖 Generated with Claude Code
Note
Medium Risk
Changes error semantics on the v2 fetch-to-store path (core replication/fetch), but replaces incorrect silent success with a detectable failure.
Overview
consumeV2FetchPackno longer returns success when a protocol v2 fetch response ends with a bare flush or EOF and never sends apackfilesection. Those paths now returnio.ErrUnexpectedEOF, aligned withopenV2PackStream, so store-based fetches cannot report success after storing nothing from a truncated or empty response.The post-
readycase still uses the existing explicit “expected packfile after ready” errors; acknowledgments-without-packfile behavior is unchanged.Tests cover a flush-only wire and an empty reader, both expecting
io.ErrUnexpectedEOF.Reviewed by Cursor Bugbot for commit 74a2fd5. Configure here.