Skip to content

Commit e92a341

Browse files
bchamppyaythomas
authored andcommitted
fix: dont fail invocations on throttling exceptions
1 parent 378e555 commit e92a341

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/aws_durable_execution_sdk_python/exceptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from typing import TYPE_CHECKING, Self, TypedDict
1212

1313
BAD_REQUEST_ERROR: int = 400
14+
TOO_MANY_REQUESTS_ERROR: int = 429
1415
SERVICE_ERROR: int = 500
1516

1617
if TYPE_CHECKING:
@@ -160,10 +161,11 @@ def from_exception(cls, exception: Exception) -> CheckpointError:
160161
status_code: int | None = (metadata and metadata.get("HTTPStatusCode")) or None
161162
if (
162163
status_code
163-
# if we are in 4xx range and is not an InvalidParameterValueException with Invalid Checkpoint Token
164+
# if we are in 4xx range (except 429) and is not an InvalidParameterValueException with Invalid Checkpoint Token
164165
# then it's an execution error
165166
and status_code < SERVICE_ERROR
166167
and status_code >= BAD_REQUEST_ERROR
168+
and status_code != TOO_MANY_REQUESTS_ERROR
167169
and error
168170
and (
169171
# is not InvalidParam => Execution

tests/exceptions_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ def test_checkpoint_error_classification_other_4xx_execution():
8383
assert result.is_retriable()
8484

8585

86+
def test_checkpoint_error_classification_429_invocation():
87+
"""Test 429 errors are invocation errors (retryable)."""
88+
error_response = {
89+
"Error": {"Code": "TooManyRequestsException", "Message": "Rate limit exceeded"},
90+
"ResponseMetadata": {"HTTPStatusCode": 429},
91+
}
92+
client_error = ClientError(error_response, "Checkpoint")
93+
94+
result = CheckpointError.from_exception(client_error)
95+
96+
assert result.error_category == CheckpointErrorCategory.INVOCATION
97+
assert not result.is_retriable()
98+
99+
86100
def test_checkpoint_error_classification_invalid_param_without_token_execution():
87101
"""Test 4xx InvalidParameterValueException without Invalid Checkpoint Token is execution error."""
88102
error_response = {

0 commit comments

Comments
 (0)