Fix 1908 - #1912
Merged
Merged
Conversation
…rossbario#1908) The existing TestDeflate.test_max_size asserted the buggy behavior: with max_message_size=10 it expected the decoder to *return* a silently truncated 10-byte payload. Truncating a compressed WAMP message corrupts it, and end_decompress_message() then raises "zlib error -3" on the mid-stream sync-flush trailer (so the only existing decompressed-size cap never produces a clean rejection). Replace it with tests asserting the intended contract: a message inflating beyond max_message_size is rejected with PayloadExceededError, both single-frame and cumulative across frames, while under-cap and exactly-at-cap messages round-trip intact (and end_decompress_message() does not raise). Two of these fail on current code, proving the missing zlib unconsumed_tail drain (crossbario#1908). Note: This work was completed with AI assistance (Claude Code).
…eanly (crossbario#1908) decompress_message_data() passed max_message_size as zlib's max_length but never drained unconsumed_tail, so an over-cap message was silently truncated to the cap and the dropped tail left the deflate stream mid-token (end_decompress_message() then raised "zlib error -3"). The cap therefore never produced a clean rejection, and it counted per-call rather than per-message. Track decompressed output per message (reset in start_decompress_message()) and cap each call at the remaining budget; if unconsumed_tail is non-empty after a call the (cumulative) message exceeds max_message_size, so raise PayloadExceededError instead of truncating. The uncapped path (max_message_size is None) is unchanged. Makes the tests added in the previous commit pass: single-frame and cumulative rejection, with under-cap and exactly-at-cap messages round-tripping intact. Note: This work was completed with AI assistance (Claude Code).
Contributor
Author
Contributor
Author
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.


this will fix #1908 - fully TDD, in two phases ("red green test proven")