thrift icon indicating copy to clipboard operation
thrift copied to clipboard

THRIFT-5905: Removed base64 and added logger as an explicit add_dependency

Open kpumuk opened this issue 1 month ago • 3 comments

base64 in Ruby 3.4

Starting with Ruby 3.4, base64 is no longer a bundled gem, and now Thrift does not load in modern Ruby versions:

An error occurred while loading ./spec/types_spec.rb.

Failure/Error: require 'base64'

LoadError:
  cannot load such file -- base64
# ./lib/thrift/protocol/json_protocol.rb:21:in '<top (required)>'
# ./lib/thrift.rb:45:in '<top (required)>'
# ./spec/spec_helper.rb:30:in '<top (required)>'
# ./spec/types_spec.rb:20:in '<top (required)>'

Ruby already has ability to serialize and deserialize base64 without requiring the base64 gem, which is a thin wrapper for syntactic sugar.

logger in Ruby 3.5

Throws a warning at the moment, and will be an error in Ruby 3.5:

/code/lib/thrift/processor.rb:20: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add logger to your Gemfile or gemspec to silence this warning.

ostruct in Ruby 3.5 (transitive dependency on Rake 12.x)

Additionally, Rake used to use ostruct, which will be removed in Ruby 4.0, and running tests produced the following warning:

/Users/dmytro/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/rake-12.3.3/lib/rake.rb:33: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.

Updated Rake version to get rid of the warning and fix the gem for Ruby 4.0 (formerly known as 3.5)

[!IMPORTANT] This is not enough to fix the gem for Ruby 3.5. Thrift currently only works with Rack 2, which also depends on ostruct without explicitly defining it (the usage was removed in Rack 3.1) Rack 3 support will require additional work.

  • [x] Did you create an Apache Jira ticket? THRIFT-5905
  • [x] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • [x] Did you squash your changes to a single commit? (not required, but preferred)
  • [x] 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.

kpumuk avatar Nov 19 '25 23:11 kpumuk

Rewrote the code to avoid the dependency on "base64".

kpumuk avatar Nov 22 '25 17:11 kpumuk

Ruby specs pass with this change https://github.com/kpumuk/thrift/actions/runs/19598791172

CleanShot 2025-11-22 at 12 32 26@2x

kpumuk avatar Nov 22 '25 17:11 kpumuk

Cross-tests pass as well https://github.com/kpumuk/thrift/actions/runs/19598908804:

CleanShot 2025-11-22 at 12 49 29@2x

kpumuk avatar Nov 22 '25 17:11 kpumuk