Skip to content

THRIFT-6013: Add recursion depth limit to skip() in Ruby library#3499

Merged
Jens-G merged 1 commit into
apache:masterfrom
Jens-G:THRIFT-6013
May 19, 2026
Merged

THRIFT-6013: Add recursion depth limit to skip() in Ruby library#3499
Jens-G merged 1 commit into
apache:masterfrom
Jens-G:THRIFT-6013

Conversation

@Jens-G
Copy link
Copy Markdown
Member

@Jens-G Jens-G commented May 19, 2026

Summary

  • Adds a max_depth parameter (default 64) to BaseProtocol#skip
  • Raises ProtocolException::DEPTH_LIMIT when the depth limit is exceeded
  • Aligns the Ruby implementation with Java, Python, Go and netstd, which already enforce this limit
  • Adds two unit tests to base_protocol_spec.rb covering the limit boundary

Test plan

  • spec/base_protocol_spec.rb — new tests: raises DEPTH_LIMIT at max_depth=0, no raise at max_depth=1 for a leaf type
  • Existing skip tests (should skip structs/maps/sets/lists) continue to pass

🤖 Generated with Claude Code

@Jens-G Jens-G requested a review from kpumuk as a code owner May 19, 2026 23:14
@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label May 19, 2026
Copy link
Copy Markdown
Member

@kpumuk kpumuk left a comment

Choose a reason for hiding this comment

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

note for myself: this change only covers the generic unknown-field skip() path. Expected-field deserialization still recurses without a limit for nested structs.

That makes this narrower than the Ruby configuration plan in THRIFT-5938, which calls for config-driven recursion enforcement in skip, generated reads, generated writes, and native paths (still in progress).

Client: rb

Aligns the Ruby skip() implementation with Java, Python, Go and netstd,
which already enforce a configurable recursion depth limit. Adds a
max_depth parameter (default 64) and raises ProtocolException::DEPTH_LIMIT
when exceeded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jens-G Jens-G merged commit f0ee5f9 into apache:master May 19, 2026
96 of 98 checks passed
@Jens-G Jens-G deleted the THRIFT-6013 branch May 21, 2026 07:35
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