Skip to content

Commit

Permalink
Fix an issue with max_attempts and validation (#2465)
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Jan 14, 2021
1 parent 5fa9d0d commit a6c0e1d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions gems/aws-sdk-core/CHANGELOG.md
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Fix an issue with `max_attempts` validation raising incorrectly.

3.111.0 (2021-01-11)
------------------

Expand Down
7 changes: 4 additions & 3 deletions gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
Expand Up @@ -176,11 +176,12 @@ def self.resolve_retry_mode(cfg)
end

def self.resolve_max_attempts(cfg)
value = (ENV['AWS_MAX_ATTEMPTS'] && ENV['AWS_MAX_ATTEMPTS'].to_i) ||
value = (ENV['AWS_MAX_ATTEMPTS']) ||
Aws.shared_config.max_attempts(profile: cfg.profile) ||
3
'3'
value = value.to_i
# Raise if provided value is not a positive integer
if !value.is_a?(Integer) || value <= 0
if value <= 0
raise ArgumentError,
'Must provide a positive integer for max_attempts profile '\
'option or for ENV[\'AWS_MAX_ATTEMPTS\']'
Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb
Expand Up @@ -48,13 +48,13 @@ module Plugins

it 'can configure max_attempts with shared config' do
allow_any_instance_of(Aws::SharedConfig)
.to receive(:max_attempts).and_return(5)
.to receive(:max_attempts).and_return('5')
expect(client.config.max_attempts).to eq(5)
end

it 'can configure max_attempts using ENV with precedence over config' do
allow_any_instance_of(Aws::SharedConfig)
.to receive(:max_attempts).and_return(3)
.to receive(:max_attempts).and_return('3')
ENV['AWS_MAX_ATTEMPTS'] = '1'
expect(client.config.max_attempts).to eq(1)
end
Expand Down

0 comments on commit a6c0e1d

Please sign in to comment.