Closed ohbarye closed 10 months ago
Although I'm unfamiliar with Sorbet, I can send an easy patch to change the type definition like the one below. I don't know if it's valid and appropriate.
sig { params(logger: T.nilable(
defined?(ActiveSupport::BroadcastLogger) ?
T.any(::Logger, Vonage::Logger, ActiveSupport::BroadcastLogger) # rails 7.1.0 introduced
: T.any(::Logger, Vonage::Logger)
)).returns(T.nilable(Vonage::Logger)) }
def logger=(logger)
end
Just to let you know, I found a runtime check behavior configuration of Sorbet.
https://sorbet.org/docs/tconfiguration#errors-from-invalid-method-calls
After executing the following code, my code stopped raising a TypeError. I feel weird about writing a config for Sorbet even though I don't use Sorbet as a user. 😓
T::Configuration.call_validation_error_handler = lambda do |signature, opts|
puts opts[:message]
end
Or, SORBET_RUNTIME_DEFAULT_CHECKED_LEVEL=tests
environment variable seems to disable raising an error.
https://sorbet.org/docs/tconfiguration#sorbet_runtime_default_checked_level
Thanks @ohbarye. I'll look into getting a fix out for this.
same issue here, is there any workarround?
@matedemorphy I'm working on a PR which basically implements @ohbarye's solution. I just need to do a bit more testing, but it should hopefully be released later today.
@ohbarye @matedemorphy the PR is now merged and released as v7.16.1 and available on RubyGems
@superchilled Thank you for your quick fix! I confirmed that v7.16.1 has resolved the type error on our codebase.
Thanks @ohbarye :bow:
Problem
Rails 7.1 introduced
ActiveSupport::BroadcastLogger
and it violates vonage's type definition.ref https://github.com/rails/rails/pull/48615
Reproduce procedure
Call
Vonage::Client.new
with rails 7.1.0 and vonage 7.16.0.Expected Behavior
No error happens.
Actual Behavior
It raises
TypeError
.Cause
That's because vonage's type definition does not allow a class that does not inherits
Logger
unlikeActiveSupport::Logger
.ref https://github.com/Vonage/vonage-ruby-sdk/blob/b3122cbf4d5953eeb4be84fec27914394628206e/lib/vonage/config.rb#L133-L135
Other information
Here is the difference of
Rails.logger
between 7.0.8 and 7.1.0.