Skip to content

[codex] fix compressed response payload boundaries#153

Open
djrobx wants to merge 1 commit into
cryptk:mainfrom
djrobx:codex/fix-zlib-payload-boundary
Open

[codex] fix compressed response payload boundaries#153
djrobx wants to merge 1 commit into
cryptk:mainfrom
djrobx:codex/fix-zlib-payload-boundary

Conversation

@djrobx

@djrobx djrobx commented Jul 4, 2026

Copy link
Copy Markdown

What changed

Uses the MsgSize supplied by an OmniLogic multi-part lead message to trim reassembled response data precisely. It also removes the rstrip(b"\x00") call before zlib decompression.

Why

The previous heuristic could remove a legitimate trailing zero from a compressed stream's zlib trailer and make zlib.decompress() raise Error -5 while decompressing data: incomplete or truncated stream. The controller already reports the exact message boundary, so there is no need to guess by removing zero bytes.

zlib.decompress() tolerates trailing protocol padding after a complete stream while continuing to reject a genuinely truncated stream.

Validation

  • Captured a live controller response: its declared MsgSize exactly matched the reassembled compressed response length.
  • Added an end-to-end regression test for a compressed stream whose valid trailer ends in 0x00, followed by protocol padding.
  • pytest -q tests (full suite)
  • Ruff lint and format checks

@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@djrobx

djrobx commented Jul 4, 2026

Copy link
Copy Markdown
Author

This is a Codex generated PR to address
#152

I happened to encounter the -5 condition that some others have run into.

Codex first gave a "fallback" code change that dropped down to a streaming Zlib when -5 was found that worked, but I pressed it to find a cleaner solution. Then it found MsgSize in the header, which I think is the proper fix. But, feel free to reject and re-implement as you see fit. :)

@djrobx djrobx marked this pull request as ready for review July 4, 2026 20:27
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.

1 participant