Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue with max_attempts and validation #2465

Merged
merged 1 commit into from Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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