Skip to content

fix: return buffered gzip data from bounded reads - #251

Merged
pyrooka merged 2 commits into
IBM:mainfrom
Shubham-Padkonde:fix/gzip-bounded-reads
Oct 6, 2026
Merged

pyrooka merged 2 commits into
IBM:mainfrom
Shubham-Padkonde:fix/gzip-bounded-reads

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

Bounded GzipStream.read(size) calls can return an empty byte string after producing compressed data, even though the internal buffer still contains bytes. Consumers interpret that as EOF and can truncate the upload.

Return up to the requested number of bytes after filling the buffer, as well as when enough bytes were already buffered. Unbounded reads retain their existing behavior.

Regression coverage decompresses complete streams read in five chunk sizes across empty, byte, Unicode text, and large inputs. It also checks that a zero-length read preserves the payload.

Validation: 224 unit tests passed, one skipped, with 99% coverage on Linux. Lint and formatting checks passed. Live IBM Cloud integration tests were not run.

@CLAassistant

CLAassistant commented Oct 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pyrooka pyrooka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small cosmetic issue to address, otherwise it looks good. Thanks for the contribution!

Comment thread ibm_cloud_sdk_core/utils.py Outdated
# Return buffered data whether it was already available or was
# produced above. An empty read must only indicate end-of-stream.
compressed = self.buffer[:size]
# then remove them from the buffer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This residual comment should be removed as it doesn't make any now.

Suggested change
# then remove them from the buffer.

Signed-off-by: Shubham Padkonde <shubhampadkonde12@gmail.com>

@pyrooka pyrooka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pyrooka
pyrooka merged commit 8b65cf7 into IBM:main Oct 6, 2026
10 checks passed
ibm-devx-sdk pushed a commit that referenced this pull request Oct 6, 2026
## [3.27.2](v3.27.1...v3.27.2) (2026-10-06)

### Bug Fixes

* return buffered gzip data from bounded reads ([#251](#251)) ([8b65cf7](8b65cf7))
@ibm-devx-sdk

Copy link
Copy Markdown

🎉 This PR is included in version 3.27.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants