Skip to content

THRIFT-6146: Validate Ruby processor message types - #3709

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-processor-message-type
Aug 13, 2026
Merged

THRIFT-6146: Validate Ruby processor message types#3709
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-processor-message-type

Conversation

@kpumuk

@kpumuk kpumuk commented Aug 12, 2026

Copy link
Copy Markdown
Member

The Ruby base processor previously dispatched incoming messages solely by function name. A message carrying a REPLY or EXCEPTION envelope could therefore reach generated request parsing and invoke a server handler instead of being rejected.

This change limits base processor dispatch to CALL and ONEWAY envelopes, matching the validation already performed by the Ruby multiplexed processor. For another envelope type, the processor consumes the message body and returns an INVALID_MESSAGE_TYPE application exception while preserving the original function name and sequence ID. Valid CALL and ONEWAY dispatch semantics remain unchanged.

Benchmarks

The server benchmark was run five times for current master and the proposed change using:

THRIFT_SERVER=Thrift::ThreadPoolServer THRIFT_PROTOCOL=binary THRIFT_NUM_PROCESSES=4 THRIFT_NUM_CLIENTS=5 THRIFT_NUM_CALLS=100 THRIFT_TLS=false ruby benchmark/benchmark.rb

Current master had a median wall time of 0.3663 seconds, with a range of 0.3458–0.3856 seconds. The proposed change had a median of 0.3570 seconds, with a range of 0.3478–0.3701 seconds, a nominal decrease of 2.5%. The runs are short enough that this difference should be treated as noise; they show no measurable regression from validating the message type on the dispatch path.

ThreadedServer could not be used because the existing benchmark harness passes five constructor arguments to a server accepting two to four, so this comparison uses ThreadPoolServer.

  • Did you create an Apache Jira ticket? THRIFT-6146
  • 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.

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
Copilot AI lite review requested due to automatic review settings August 12, 2026 14:58

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 hardens the Ruby base processor dispatch path by validating incoming Thrift message envelope types before dispatching to generated request parsing / handler invocation, preventing REPLY/EXCEPTION envelopes from being treated as server requests.

Changes:

  • Add message-type validation in Thrift::Processor#process, allowing only CALL and ONEWAY.
  • For invalid envelope types, consume the incoming message body and respond with an INVALID_MESSAGE_TYPE ApplicationException while preserving function name and sequence id.
  • Add Ruby specs covering rejection of invalid message types and preserving existing dispatch semantics for valid types (including generated processor behavior edge cases).

Reviewed changes

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

File Description
lib/rb/spec/processor_spec.rb Adds unit tests for rejecting REPLY/EXCEPTION envelopes and confirming unchanged CALL/ONEWAY dispatch behavior.
lib/rb/lib/thrift/processor.rb Enforces envelope-type validation in the base processor and emits INVALID_MESSAGE_TYPE errors for invalid types.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label Aug 12, 2026
@kpumuk
kpumuk merged commit 4d0faf3 into apache:master Aug 13, 2026
94 of 95 checks passed
@kpumuk
kpumuk deleted the rb-processor-message-type branch August 13, 2026 12:34
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.

2 participants