Skip to content

Commit

Permalink
Add additional waiter config validation for matching error codes
Browse files Browse the repository at this point in the history
We should validate that if an error matcher references an error code,
then the operation actually has a modeled error with a matching code.

This won't pass as is, so I'm adding this as a reference for now.
We likely won't be able to get all the service models updated
immediately, so we may need to allow list existing cases that are valid
but not fully modeled.
  • Loading branch information
jamesls committed Sep 11, 2024
1 parent 2707445 commit 74745b9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/functional/test_waiter_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ def _validate_acceptor(acceptor, op_model, waiter_name):
f"'{waiter_name}' with non list result in JMESPath expression: "
f"{expression}"
)
if acceptor.matcher == 'error':
expected_code = acceptor.expected
all_codes = [shape.error_code for shape in op_model.error_shapes]
if expected_code not in all_codes:
raise AssertionError(
f"The '{waiter_name}' waiter for the "
f"'{op_model.service_model.service_name}' service that defines"
f"a matcher with error code {expected_code} that's not in "
f"the error codes defined in the {op_model.name} operation "
f"model: {', '.join(all_codes)}"
)


def _search_jmespath_expression(expression, op_model):
Expand Down

0 comments on commit 74745b9

Please sign in to comment.