-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
Semian::RedisV5Client#translate_error! overrides Redis::Client.translate_error! via prepend but doesn't preserve the original method signature. This might cause an ArgumentError when used alongside the redis-clustering gem.
This can happen even if you do not pass the semian argument to a Redis::Cluster class
def translate_error!(error, mapping: ERROR_MAPPING)
redis_error = translate_error_class(error.class, mapping: mapping)
raise redis_error, error.message, error.backtrace
endSemian's patch:
Lines 54 to 70 in 568d073
| module RedisV5Client | |
| def translate_error!(error) | |
| redis_error = translate_error_class(error.class) | |
| if redis_error < ::Semian::AdapterError | |
| redis_error = redis_error.new(error.message) | |
| redis_error.semian_identifier = error.semian_identifier | |
| if error.respond_to?(:semian_open_circuit_on_oom) && redis_error.respond_to?(:semian_open_circuit_on_oom=) | |
| redis_error.semian_open_circuit_on_oom = error.semian_open_circuit_on_oom | |
| end | |
| end | |
| raise redis_error, error.message, error.backtrace | |
| end | |
| end | |
| end | |
| ::Redis.prepend(Semian::RedisV5) | |
| ::Redis::Client.singleton_class.prepend(Semian::RedisV5Client) |
Now when Redis::Cluster::Client calls its translate_error!, it would delegate to Redis::Client:
def translate_error!(error, mapping: ERROR_MAPPING)
case error
when RedisClient::Cluster::ErrorCollection
# nothing in particular
else
Redis::Client.translate_error!(error, mapping: mapping) # <---- DELEGATES HERE
end
endBut the Semian's patch breaks the API, which causes a ArgumentError: wrong number of arguments (given 2, expected 1).
Tested with:
semian 0.27.1 (latest)
redis 5.4.1 (latest)
redis-clustering 5.4.1 (latest)
redis-client 0.26.4 (latest)
But likely it's been an issue for longer.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels