THRIFT-6103: Return unsigned values from Ruby MemoryBufferTransport#3644
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an inconsistency in the Ruby native extension for MemoryBufferTransport#read_byte, which previously returned signed values for bytes >= 0x80 due to storing the byte in a char. The native implementation is updated to return unsigned 0..255 values, matching the pure-Ruby transport and the BaseTransport#read_byte contract.
Changes:
- Update the native
MemoryBufferTransport#read_byteimplementation to read bytes asunsigned charand return0..255. - Add a spec asserting
read_bytereturns unsigned values for representative boundary bytes (0x00,0x7f,0x80,0xff).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/rb/spec/base_transport_spec.rb | Adds coverage to ensure read_byte returns unsigned 0..255 values. |
| lib/rb/ext/memory_buffer.c | Fixes native read_byte to return unsigned byte values consistently. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…alues Client: rb Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
Member
Code reviewNo issues found. Checked for bugs, AGENTS.md compliance, and security implications. 🤖 Generated with Claude Code |
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.
The native
MemoryBufferTransport#read_byteimplementation returned signed values for bytes above0x7fbecause it stored the byte in a plain Cchar. The pure-Ruby implementation returns unsigned values, making direct raw-byte consumers depend on extension availability and platform representation.The native transport now returns the same
0..255byte values as the pure-Ruby implementation.[skip ci]anywhere in the commit message to free up build resources.