THRIFT-6045: Add recursion-depth round-trip test for the Ruby library#3550
Merged
Conversation
kpumuk
requested changes
May 28, 2026
Member
kpumuk
left a comment
There was a problem hiding this comment.
This PR is insufficient:
- It only covers pure Ruby implementation, and not the native extension
- It does not cover Union
- There are no tests
I am currently working on https://issues.apache.org/jira/browse/THRIFT-5938, with recursion depth enforcement being a part of the problem. I can extract my change to merge it ahead of the configuration class
84c4704 to
d7a6fff
Compare
Member
Author
It is way more than that. That#s hy I made it a draft. Different story.
Ok I only push the test then and leave it up to you, including the ticket. |
d7a6fff to
fa9ce28
Compare
Client: rb Adds a round-trip regression test for struct/union/exception recursion depth without the implementation; the limit itself is left to a follow-up. spec/recursion_depth_spec.rb drives the generated read/write path over recursive RecTree (struct), RecUnion (union) and RecError (exception) types added to ThriftSpec.thrift, across BinaryProtocol and BinaryProtocolAccelerated. The round-trip / within-limit cases (a chain at the limit, a wide shallow tree, a struct through a MultiplexedProtocol, and the exception round-trip) are active. The limit-enforcement cases (over-limit struct/union/exception write and read) are marked pending: the Ruby library does not bound recursion depth yet, so they are expected to fail until the limit is added, at which point RSpec flags them to be enabled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fa9ce28 to
d15e539
Compare
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.
THRIFT-6045: Add a recursion-depth round-trip test for the Ruby library
This is a test-only change — it adds the regression test without the implementation; the limit itself is left to a follow-up (see the discussion below).
spec/recursion_depth_spec.rbdrives the generated read/write path (Thrift::Struct#read/#write,Thrift::Union#read/#write) over recursiveRecTree(struct),RecUnion(union) andRecError(exception) types added toThriftSpec.thrift, acrossBinaryProtocoland (when the native extension is loaded)BinaryProtocolAccelerated.MultiplexedProtocol, and the exception round-trip.The over-limit read payloads are hand-serialized with the real recursive field (id 1,
list<self>) so a future guarded reader recurses through the generated path rather thanskip().Validated locally (Ruby 3.0.2, pure-Ruby): 10 examples, 0 failures, 5 pending. Implementation note for the follow-up: the native
thrift_nativeC extension rebindsThrift::Struct#read/#write, so a complete fix must also guardrb_thrift_struct_write/read(and the union equivalents) in C, not only the pure-Ruby path.🤖 Generated with Claude Code