Skip to content

Conversation

alexgromero
Copy link

Description of changes:
Adds support for a new retry mode: standard. This behavior is now consistent with other AWS SDKs implementing standard mode. This mode also adds support for retry quotas which control how many unsuccessful retries a client can make.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@alexgromero alexgromero requested a review from a team as a code owner August 22, 2025 18:28
### Features

* Added a hand-written implmentation for the `restJson1` protocol.
* Added a new retry mode `standard` and made it the default retry strategy.
Copy link
Author

Choose a reason for hiding this comment

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

Is this considered a feature or breaking change since we're updating a default?

Copy link
Contributor

@jonathan343 jonathan343 left a comment

Choose a reason for hiding this comment

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

Thanks Alessandra!
Looks great so far. I have a few suggestions below.

async def refresh_retry_token_for_retry(
self,
*,
token_to_renew: StandardRetryToken,
Copy link
Contributor

@jonathan343 jonathan343 Aug 28, 2025

Choose a reason for hiding this comment

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

This is going to result in the following typechecker errors:

/.../smithy-python/packages/smithy-core/src/smithy_core/retries.py
  /.../smithy-python/packages/smithy-core/src/smithy_core/retries.py:288:15 - error: Method "refresh_retry_token_for_retry" overrides class "RetryStrategy" in an incompatible manner
    Keyword parameter "token_to_renew" type mismatch: base parameter is type "RetryToken", override parameter is type "StandardRetryToken"
      "RetryToken" is not assignable to "StandardRetryToken" (reportIncompatibleMethodOverride)
  /.../smithy-python/packages/smithy-core/src/smithy_core/retries.py:331:15 - error: Method "record_success" overrides class "RetryStrategy" in an incompatible manner
    Keyword parameter "token" type mismatch: base parameter is type "RetryToken", override parameter is type "StandardRetryToken"
      "RetryToken" is not assignable to "StandardRetryToken" (reportIncompatibleMethodOverride)

I think we need to be using retries_interface.RetryToken here instead of StandardRetryToken.

Suggested change
token_to_renew: StandardRetryToken,
token_to_renew: retries_interface.RetryToken,

Making this change alone will result in even more typing errors because StandardRetryToken has extra attributes. I think we have the following options:

  • Use typing.cast to tell the typechecker we're using StandardRetryToken
  • Add a runtime check to validate StandardRetryToken is being used

:param max_attempts: Upper limit on total number of attempts made, including
initial attempt and retries.
"""
self.backoff_strategy = ExponentialRetryBackoffStrategy(
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the max_backoff is 20 seconds and it would be a bit redundant to specify that here, but I feel like that is the safer thing to do. If for some reason we decided that a different default is better for non-AWS clients, I don't want us to accidentally change the value used here.

initial attempt and retries.
"""
self.backoff_strategy = ExponentialRetryBackoffStrategy(
backoff_scale_value=1,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - Not really relevant to this PR, but we should consider adding some simple validation for these values on initialization (e.g., ensure they're positive integers).

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.

2 participants