fix(storage): compression upload & cache correctness fixes#3231
Conversation
PR SummaryMedium Risk Overview Decompression and chunker: Frame lookup and cache: GCS multipart: Part uploads use explicit Reviewed by Cursor Bugbot for commit 16bc458. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request introduces critical integrity and reliability fixes to the storage and caching mechanisms. It ensures that decompression and CRC errors are properly surfaced during reader closure, preventing corrupt or truncated frames from being cached or served. It also resolves S3/GCS multipart upload issues, such as handling HTTP 200 responses containing XML error payloads and avoiding chunked transfer encoding for empty parts. Feedback on the changes suggests making the new integrityReader's Close method idempotent by clearing the onFail callback after its first invocation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22e613c139
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
22e613c to
91721cc
Compare
744251a to
871235f
Compare
91721cc to
3ad30bb
Compare
871235f to
d0c5642
Compare
3ad30bb to
6220dcf
Compare
d0c5642 to
3f7e772
Compare
6220dcf to
afc4287
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit afc4287. Configure here.
afc4287 to
d11cd84
Compare
An exact-size read of a compressed frame never pulls the zstd footer through the decoder, so a footer-corrupt or truncated frame decoded as success. Close now drains to EOF (bounded to one frame) and surfaces the codec's CRC/truncation error.
LocateCompressed returned the containing frame for a mid-frame offset, so a decode silently served data from the frame start instead of the requested position. Reject non-frame-aligned offsets; callers align via LocateUncompressed.
f3070b8 to
14ac0e1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14ac0e11bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A fetch returning corrupt bytes at the expected length passed the size-only writeback guard and was cached, so every later read served the corruption. Gate the writeback on decode success and evict a cached frame that fails to decode, so reads recover once the source heals.
01bc002 to
a842e0f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a842e0f793
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ters progressiveFetch advanced waiters as bytes streamed and only recorded the reader Close error in metrics, so a corrupt compressed frame could be served to guests and marked cached before its CRC was checked. Defer waiter release for compressed chunks until after verification, and fail the fetch on a Close/CRC error.
retryablehttp only sets ContentLength for ReaderFunc bodies that implement LenReader; io.SectionReader does not, so compressed parts went out chunked-encoded with no Content-Length. Real GCS tolerates chunked uploads, but S3-compatible XML backends reject them with 411, and an explicit length lets the server validate the payload up front. Give multiSliceReader a Len method (picked up by retryablehttp and persisted across retries) and send no body at all for empty parts — a zero-length reader still counts as unknown length to net/http and would be chunked. The MinIO-backed TestGCSXML* tests, which reject chunked parts, now guard this against regression.
a842e0f to
35a5f0a
Compare
The GCS XML API (like S3) can return HTTP 200 with an <Error> body when a commit fails server-side. completeUpload only checked the status code, so a failed commit was recorded as success — storing a frame table for an object that was never written. Parse the body and fail on an <Error> root.
A zero-length *bytes.Reader is "unknown length" to net/http and is sent chunked, which S3-compatible XML backends reject with 411. Pass no body for empty parts so Content-Length: 0 is sent instead.
35a5f0a to
16bc458
Compare

Split out from #3113. Stacked on #3230 (units refactor).
Correctness fixes to the existing compressed-upload / cache / chunker code (all independent of the AWS feature):
Two GCS fix-tests (empty-part, Content-Length) that require the MinIO/fake-GCS testcontainer harness are exercised in the stacked tests PR, since that harness lives there.
Verified: shared storage suite green; orchestrator block suite green (Linux container).