Fix zstd decompression for multi-frame responses#12268
Open
r266-tech wants to merge 1 commit intoaio-libs:masterfrom
Open
Fix zstd decompression for multi-frame responses#12268r266-tech wants to merge 1 commit intoaio-libs:masterfrom
r266-tech wants to merge 1 commit intoaio-libs:masterfrom
Conversation
ZstdDecompressor from compression.zstd cannot handle inputs containing multiple compressed frames. When a server sends zstd-encoded data in multiple frames (e.g., chunked transfer encoding with separate flushes), the decompressor raises EOFError: 'Already at the end of a Zstandard frame'. This fix: - Catches EOFError when a frame ends and creates a new decompressor - Handles multiple frames arriving in a single chunk via unused_data - Adds a regression test for multi-frame zstd decompression Fixes aio-libs#12234
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12268 +/- ##
==========================================
- Coverage 99.11% 99.10% -0.01%
==========================================
Files 130 130
Lines 45432 45451 +19
Branches 2400 2401 +1
==========================================
+ Hits 45028 45043 +15
- Misses 273 276 +3
- Partials 131 132 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
What do these changes do?
Fix zstd decompression failing with
ClientPayloadErrorwhen a server sends zstd-encoded data in multiple frames (e.g., chunked transfer encoding with separate flushes per chunk).The root cause is that
compression.zstd.ZstdDecompressorcannot handle inputs containing multiple compressed frames — it raisesEOFError: Already at the end of a Zstandard framewhen encountering a second frame after the first one ends.This fix:
EOFErrorwhen a frame ends and creates a newZstdDecompressorfor the next frameunused_dataAre there changes in behavior for the user?
Servers that send zstd responses in multiple frames (which is valid per the zstd spec) will now work correctly instead of raising
ClientPayloadError.Related issue number
Fixes #12234
Checklist
CHANGES/12234.bugfix.rst(if applicable)