@@ -9,24 +9,11 @@ module Retry
99 # Should the number of retries be reached without success, the last exception will be raised
1010 #
1111 # @param log [Logger] The logger to use for retryable logging
12- # @raise [ArgumentError] If no logger is provided or configuration values are invalid
12+ # @raise [ArgumentError] If no logger is provided
1313 # @return [void]
1414 def self . setup! ( log : nil , log_retries : ENV . fetch ( "RETRY_LOG_RETRIES" , "true" ) == "true" )
1515 raise ArgumentError , "a logger must be provided" if log . nil?
1616
17- # Security: Validate and bound retry configuration values
18- retry_sleep = ENV . fetch ( "DEFAULT_RETRY_SLEEP" , "1" ) . to_i
19- retry_tries = ENV . fetch ( "DEFAULT_RETRY_TRIES" , "10" ) . to_i
20-
21- # Bounds checking to prevent resource exhaustion
22- if retry_sleep < 0 || retry_sleep > 300 # Max 5 minutes between retries
23- raise ArgumentError , "DEFAULT_RETRY_SLEEP must be between 0 and 300 seconds, got: #{ retry_sleep } "
24- end
25-
26- if retry_tries < 1 || retry_tries > 50 # Max 50 retries to prevent infinite loops
27- raise ArgumentError , "DEFAULT_RETRY_TRIES must be between 1 and 50, got: #{ retry_tries } "
28- end
29-
3017 log_method = lambda do |retries , exception |
3118 # :nocov:
3219 if log_retries
@@ -41,8 +28,8 @@ def self.setup!(log: nil, log_retries: ENV.fetch("RETRY_LOG_RETRIES", "true") ==
4128 Retryable . configure do |config |
4229 config . contexts [ :default ] = {
4330 on : [ StandardError ] ,
44- sleep : retry_sleep ,
45- tries : retry_tries ,
31+ sleep : ENV . fetch ( "DEFAULT_RETRY_SLEEP" , "1" ) . to_i ,
32+ tries : ENV . fetch ( "DEFAULT_RETRY_TRIES" , "10" ) . to_i ,
4633 log_method :
4734 }
4835 end
0 commit comments