-
Notifications
You must be signed in to change notification settings - Fork 869
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
Adding attempt count to error message #5834
base: master
Are you sure you want to change the base?
Conversation
core/sdk-core/src/test/java/software/amazon/awssdk/core/exception/SdkExceptionMessageTest.java
Show resolved
Hide resolved
...sdk-core/src/test/java/software/amazon/awssdk/core/client/handler/SyncClientHandlerTest.java
Outdated
Show resolved
Hide resolved
core/sdk-core/src/main/java/software/amazon/awssdk/core/exception/SdkDiagnostics.java
Outdated
Show resolved
Hide resolved
core/sdk-core/src/main/java/software/amazon/awssdk/core/exception/SdkDiagnostics.java
Outdated
Show resolved
Hide resolved
core/sdk-core/src/main/java/software/amazon/awssdk/core/exception/SdkException.java
Outdated
Show resolved
Hide resolved
...k-core/src/test/java/software/amazon/awssdk/core/client/AsyncClientHandlerExceptionTest.java
Outdated
Show resolved
Hide resolved
Quality Gate failedFailed conditions |
assertThat(e.numAttempts()).isEqualTo(6); | ||
} | ||
|
||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider ParamterizedTest if we are just testing with different params.
.requestId("requestId") | ||
.build(); | ||
|
||
assertThat(e.getMessage()).contains("(SDK Diagnostics: numAttempts = 6)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we verify the entire message so that we know there are no duplicated entries? I know it's not a good practice in general, but we are the owner of the client and we should make sure we emit the right logs :)
AwsServiceException exception = assertThrows(AwsServiceException.class, | ||
() -> callAllTypes(client)); | ||
|
||
assertThat(exception.getMessage()).contains("numAttempts = 2"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, can we verify the entire message?
Motivation and Context
Improve debugging visibility by making attempt count immediately visible in exception messages. Currently, attempt information is only available through suppressed exceptions, requiring additional code to access. This change makes attempts visible directly in the exception message, matching behavior in other AWS SDKs.
Modifications
SdkException
AwsServiceException
to include attempts in AWS error detailsRetryableStageHelper
to track and propagate attempt counts during retriesTesting
ExceptionAttemptMessageBehaviorTest
testing with different retry scenariosAwsServiceExceptionTest
andSdkExceptionSerializationTest
to verify attempt count behaviorSdkExceptionMessageTest
for new attempt count functionalityVisualization of changes:
Before change:
After change:
Potential Impact:
Test or error handling code that relies on exact exception message matching might break as messages now include attempt count. We recommend using partial message matching for more resilient tests and error handling.