Skip to content

fix: cancel context on error to prevent incomplete cache uploads#283

Merged
joshfriend merged 8 commits intomainfrom
jfriend/abort-incomplete-uploads
Apr 30, 2026
Merged

fix: cancel context on error to prevent incomplete cache uploads#283
joshfriend merged 8 commits intomainfrom
jfriend/abort-incomplete-uploads

Conversation

@joshfriend
Copy link
Copy Markdown
Contributor

@joshfriend joshfriend commented Apr 30, 2026

Cancel the create context before closing cache writers on error paths, preventing partial or corrupt data from being persisted. Fixes all 8 call sites across snapshot, client, CLI, git bundle, gomod, HTTP fetch, API v1, and strategy handler.

@joshfriend joshfriend requested a review from a team as a code owner April 30, 2026 00:45
@joshfriend joshfriend requested review from worstell and removed request for a team April 30, 2026 00:45
@joshfriend joshfriend force-pushed the jfriend/s3-crc64-checksum branch from 9d08b8e to fdcfc26 Compare April 30, 2026 00:45
Base automatically changed from jfriend/s3-crc64-checksum to main April 30, 2026 00:47
Cancel the create context on archive failure so Close() aborts the
upload instead of persisting partial or corrupt data.
@joshfriend joshfriend force-pushed the jfriend/abort-incomplete-uploads branch from 636e952 to e73b78c Compare April 30, 2026 00:59
@joshfriend joshfriend marked this pull request as draft April 30, 2026 01:04
Cancel the create context before closing the writer so partial data
is not persisted when io.Copy fails.
Cancel the create context before closing the writer so partial bundle
data is not persisted when Write fails.
@joshfriend joshfriend force-pushed the jfriend/abort-incomplete-uploads branch 2 times, most recently from ca3efdd to 0f6c820 Compare April 30, 2026 01:10
Cancel the create context before closing the writer so partial data
is not persisted when io.Copy or Seek fails. Remove defer wc.Close()
which would complete the upload even on error.
Cancel the create context before closing the writer so partial data
is not persisted when Archive fails.
Cancel the create context when the upstream response body errors
mid-stream, preventing partial data from being persisted.
Cancel the create context when the upstream response body errors
mid-stream, preventing partial data from being persisted.
Cancel the create context and close the writer when io.Copy fails,
preventing partial data from being persisted and fixing a writer leak.
@joshfriend joshfriend force-pushed the jfriend/abort-incomplete-uploads branch from 0f6c820 to f2d99ca Compare April 30, 2026 01:14
@joshfriend joshfriend marked this pull request as ready for review April 30, 2026 01:15
@joshfriend joshfriend changed the title fix: abort incomplete cache uploads on archive failure fix: cancel context on error to prevent incomplete cache uploads Apr 30, 2026
@joshfriend joshfriend merged commit 447f64f into main Apr 30, 2026
9 checks passed
@joshfriend joshfriend deleted the jfriend/abort-incomplete-uploads branch April 30, 2026 01:16
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.

2 participants