Fix zstd upload decoder rejecting exact-buffer-multiple blobs - #2594
Closed
erneestoc wants to merge 1 commit into
Closed
Fix zstd upload decoder rejecting exact-buffer-multiple blobs#2594erneestoc wants to merge 1 commit into
erneestoc wants to merge 1 commit into
Conversation
The streaming zstd upload decoder's inner loop kept polling after a frame finished whenever the last run filled the output buffer exactly. Polling a finished decoder returns the input-size hint for a NEW frame header, and the post-EOF truncation check then misreported the fully-decoded stream as ending mid-frame. Deterministic for any blob whose decompressed size is an exact multiple of the decoder output buffer size, so a spec-conforming compressed-blobs upload (e.g. Bazel with --remote_cache_compression) of such a blob fails with InvalidArgument. Exit the drain loop when the decoder reports the frame complete and flushed (hint == 0), regardless of whether the output buffer was filled exactly. Regression test fails without the fix and passes with it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UXVtatcR9YMecBiu9RjwpC
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
closed as it's in #2596 |
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
The streaming zstd decoder for REAPI
compressed-blobsuploads(
stream_decode_compressed_upload) misreports a fully-decoded stream astruncated whenever the blob's decompressed size is an exact multiple of the
decoder output buffer size (
DCtx::out_size(), 128KiB-class). The finalrunfills the output buffer exactly withhint == 0(frame complete andflushed), but the drain loop treated a full output buffer as "may have more
to flush" and polled the finished decoder once more. A finished decoder
returns the input-size hint for a new frame header, so the post-EOF
frame_input_hint != 0truncation check fires and the upload fails withInvalidArgument("stream ended in the middle of a zstd frame").This is deterministic and hits spec-conforming clients today: a Bazel
upload with
--remote_cache_compressionfails for any blob whoseuncompressed size lands on the buffer-multiple boundary.
Fix
Exit the drain loop when the decoder reports the frame complete and fully
flushed (
hint == 0), regardless of whether the output buffer was filledexactly. One condition change plus an explanatory comment.
Verification
decode_accepts_exact_output_buffer_multiple(1MiB blob, exact multiple of the output buffer): fails without the
fix (misreported as truncated), passes with it.
//nativelink-service/...14/14 including clippy pedanticcargo check --tests --workspaceclean;wire-compression cargo suite 10/10.
Found while building compressed-upload support for NativeLink's own
GrpcStoretransfers, where round-trip tests hit the boundary case.🤖 Generated with Claude Code
https://claude.ai/code/session_01UXVtatcR9YMecBiu9RjwpC
This change is