-
Notifications
You must be signed in to change notification settings - Fork 866
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
Quality Gate passedIssues Measures |
} | ||
|
||
@Test | ||
public void create_WithoutAttemptCount_UsesDefaultValue() { |
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.
Maybe it's me that is confused, but test name says WithoutAttemptCount
but we set numAttempt
to 6?
@@ -115,7 +115,7 @@ public void successfulExecutionCallsResponseHandler() throws Exception { | |||
|
|||
@Test | |||
public void failedExecutionCallsErrorResponseHandler() throws Exception { | |||
SdkServiceException exception = SdkServiceException.builder().message("Uh oh!").statusCode(500).build(); | |||
SdkServiceException exception = (SdkServiceException) SdkServiceException.builder().message("Uh oh!").statusCode(500).numAttempts(1).build(); |
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.
Why do we need to cast here? Does the type return when calling .build()
change? It should not change as it is a public API
import software.amazon.awssdk.annotations.SdkProtectedApi; | ||
|
||
@SdkProtectedApi | ||
public class SdkDiagnostics { |
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.
coul you implement the ToCopyableBuilder
interface here? with the build extending the Builder
interface? You can look at EndpointDiscoveryEndpoint for an example
} | ||
|
||
public SdkDiagnostics.Builder toBuilder() { | ||
return new SdkDiagnostics.BuilderImpl(); |
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.
the builder instance returned should have the numAttempt
of this
instance
* @param numAttempts The attempt count | ||
* @return This method for object chaining | ||
*/ | ||
Builder numAttempts(Integer numAttempts); |
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.
could you add default
and throw new UnsupportedOperationException
for this method and numAttempts()
? As this is a public API, there is a small chance that users might extends this interface, and it would break them at compile time since they are not implementing these methods
@@ -122,7 +122,7 @@ public void marshallerThrowsReportedThroughFuture() throws Exception { | |||
public void responseHandlerThrowsReportedThroughFuture() throws Exception { | |||
final SdkClientException e = SdkClientException.create("Could not handle response"); | |||
when(responseHandler.handle(any(SdkHttpFullResponse.class), any(ExecutionAttributes.class))).thenThrow(e); | |||
doVerify(() -> clientHandler.execute(executionParams), e); | |||
doVerify(() -> clientHandler.execute(executionParams), thrown -> thrown.getCause() instanceof SdkClientException); |
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 did the thrown exception type changed?
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.