Skip to content

THRIFT-6103: Return unsigned values from Ruby MemoryBufferTransport#3644

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-unsigned-byte
Jul 20, 2026
Merged

THRIFT-6103: Return unsigned values from Ruby MemoryBufferTransport#3644
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-unsigned-byte

Conversation

@kpumuk

@kpumuk kpumuk commented Jul 19, 2026

Copy link
Copy Markdown
Member

The native MemoryBufferTransport#read_byte implementation returned signed values for bytes above 0x7f because it stored the byte in a plain C char. 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..255 byte values as the pure-Ruby implementation.

  • Did you create an Apache Jira ticket? THRIFT-6103
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Copilot AI review requested due to automatic review settings July 19, 2026 18:50
@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label Jul 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_byte implementation to read bytes as unsigned char and return 0..255.
  • Add a spec asserting read_byte returns 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.

Copilot AI review requested due to automatic review settings July 20, 2026 15:57
@kpumuk
kpumuk force-pushed the rb-unsigned-byte branch from 3bedbf4 to 9e70b60 Compare July 20, 2026 15:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

…alues

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.4) <codex@openai.com>
@kpumuk
kpumuk force-pushed the rb-unsigned-byte branch from 9e70b60 to 89df379 Compare July 20, 2026 21:29
Copilot AI review requested due to automatic review settings July 20, 2026 21:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@kpumuk
kpumuk merged commit d2001f7 into apache:master Jul 20, 2026
94 of 95 checks passed
@kpumuk
kpumuk deleted the rb-unsigned-byte branch July 20, 2026 22:00
@Jens-G

Jens-G commented Jul 20, 2026

Copy link
Copy Markdown
Member

Code review

No issues found. Checked for bugs, AGENTS.md compliance, and security implications.

🤖 Generated with Claude Code

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

Labels

ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants