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

feature(Waiters): Add the reason for failure in the exception thrown whenever a waiter transitions to a failure state. #5230

Merged
merged 6 commits into from
May 18, 2024

Conversation

joviegas
Copy link
Contributor

@joviegas joviegas commented May 16, 2024

Motivation and Context

Currently the Waiter fails with below message

software.amazon.awssdk.core.exception.SdkClientException: A waiter acceptor was matched and transitioned the waiter to failure state

Issues like 2262 and also customer requests to add more info whenever a waiter fails. With multiple failure conditionals acceptors, its difficult for the user why exactly the Waiter failed.

This PR makes the exception message to have reason of failure in its message.

Modifications

  • Modified the Waiter creation logic so that Message method passes valid message for Failure State transiotion

When Waiter fails due to Response Field

        {
          "state": "failure",
          "matcher": "path",
          "argument": "StringMember",
          "expected": "UNEXPECTED_VALUE"
        },

Error Message

A waiter acceptor with the matcher (path) was matched on parameter (StringMember=UNEXPECTED_VALUE) and transitioned the waiter to failure state.

Failure message for failure due to Status code

        {
          "state": "failure",
          "matcher": "status",
          "expected": 500
        }

Error Message

A waiter acceptor was matched to response status 500 and transitioned the waiter to failure state

Failure message for failure due to Errors

        {
          "matcher": "error",
          "expected": true,
          "state": "failure"
        }

Error Message

A waiter acceptor was matched on error condition (true) and transitioned the waiter to failure state

With Error code causing the failure

        {
          "matcher": "error",
          "expected": "EmptyModeledException",
          "state": "success"
        }

The exception is

A waiter acceptor was matched on error condition (EmptyModeledException) and transitioned the waiter to failure state

Testing

  • Junits

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

License

  • I confirm that this pull request can be released under the Apache 2 license

…whenever a waiter transitions to a failure state
@joviegas joviegas requested a review from a team as a code owner May 16, 2024 22:51
@joviegas joviegas force-pushed the joviegas/waiter_failure_status_update branch 2 times, most recently from cb34e52 to c5baa96 Compare May 16, 2024 23:24
@@ -24,6 +25,10 @@ import software.amazon.awssdk.utils.ToString;
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public final class WaitersRuntime {

public static final String FAILURE_MESSAGE_FORMAT_FOR_STATUS_MATCHER = "A waiter acceptor was matched to response status %d"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: private?

A waiter acceptor was matched on HTTP response status code (%s) ....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the message to similar as below suggestion An error waiter acceptor was matched...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we are just missing parentheses around HTTP response status code (%d)

@@ -69,6 +70,11 @@
*/
public abstract class BaseWaiterClassSpec implements ClassSpec {

public static final String FAILURE_MESSAGE_FORMAT_FOR_PATH_MATCHER = "A waiter acceptor with the matcher %s matched the "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting the following:

An error waiter acceptor with the matcher (%s) was matched on parameter (%s=%s) and 
transitioned the waiter to failure state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was wondering why error waiter acceptor and not just waiter acceptor since the marcher is based on path and not a error matcher

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that it's an error waiter acceptor because it leads the request to failure. I can see how it's confusing. NVM then!

public static final String FAILURE_MESSAGE_FORMAT_FOR_PATH_MATCHER = "A waiter acceptor with the matcher %s matched the "
+ "expected value %s for the argument %s "
+ "and transitioned the waiter to failure state";
public static final String FAILURE_MESSAGE_FORMAT_FOR_ERROR_MATCHER = "A waiter acceptor was matched to error condition "
Copy link
Contributor

@zoewangg zoewangg May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting the following:

An error waiter acceptor was matched on error condition (%s) and ...

@joviegas joviegas force-pushed the joviegas/waiter_failure_status_update branch from c5baa96 to 56d96da Compare May 17, 2024 18:48
@joviegas joviegas enabled auto-merge (squash) May 17, 2024 21:44
Copy link

sonarcloud bot commented May 18, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
37.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@joviegas joviegas merged commit 0bbf1b4 into master May 18, 2024
16 of 17 checks passed
akidambisrinivasan pushed a commit to akidambisrinivasan/aws-sdk-java-v2 that referenced this pull request Jun 28, 2024
…whenever a waiter transitions to a failure state. (aws#5230)

* feature(Waiters): Add the reason for failure in the exception thrown whenever a waiter transitions to a failure state

* Handle review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants