Skip to content

Commit

Permalink
Handle expected boolean values for waiter error matcher (#3073)
Browse files Browse the repository at this point in the history
  • Loading branch information
jterapin committed Aug 8, 2024
1 parent 0bbdf11 commit 7ffb83b
Show file tree
Hide file tree
Showing 6 changed files with 470 additions and 122 deletions.
2 changes: 2 additions & 0 deletions gems/aws-sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Update waiters to handle expected boolean values when matching errors.

3.201.3 (2024-07-23)
------------------

Expand Down
13 changes: 9 additions & 4 deletions gems/aws-sdk-core/lib/aws-sdk-core/waiters/poller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize(options = {})
# * `:retry` - The waiter may be retried.
# * `:error` - The waiter encountered an un-expected error.
#
# @example A trival (bad) example of a waiter that polls indefinetly.
# @example A trivial (bad) example of a waiter that polls indefinetly.
#
# loop do
#
Expand Down Expand Up @@ -96,8 +96,13 @@ def matches_status?(acceptor, response)
end

def matches_error?(acceptor, response)
Aws::Errors::ServiceError === response.error &&
response.error.code == acceptor['expected'].delete('.')
case acceptor['expected']
when 'false' then response.error.nil?
when 'true' then !response.error.nil?
else
response.error.is_a?(Aws::Errors::ServiceError) &&
response.error.code == acceptor['expected'].delete('.')
end
end

def path(acceptor)
Expand All @@ -107,7 +112,7 @@ def path(acceptor)
def non_empty_array(acceptor, response, &block)
if response.data
values = JMESPath.search(path(acceptor), response.data)
Array === values && values.count > 0 ? yield(values) : false
values.is_a?(Array) && values.count > 0 ? yield(values) : false
else
false
end
Expand Down
Loading

0 comments on commit 7ffb83b

Please sign in to comment.