@@ -9,24 +9,11 @@ module Retry
9
9
# Should the number of retries be reached without success, the last exception will be raised
10
10
#
11
11
# @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
13
13
# @return [void]
14
14
def self . setup! ( log : nil , log_retries : ENV . fetch ( "RETRY_LOG_RETRIES" , "true" ) == "true" )
15
15
raise ArgumentError , "a logger must be provided" if log . nil?
16
16
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
-
30
17
log_method = lambda do |retries , exception |
31
18
# :nocov:
32
19
if log_retries
@@ -41,8 +28,8 @@ def self.setup!(log: nil, log_retries: ENV.fetch("RETRY_LOG_RETRIES", "true") ==
41
28
Retryable . configure do |config |
42
29
config . contexts [ :default ] = {
43
30
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 ,
46
33
log_method :
47
34
}
48
35
end
0 commit comments