Skip to content

Commit 810647f

Browse files
fix: exceed payload size limit as invocation error
Throw CheckpointError with error_category as INVOCATION for 4xx InvalidParameterValueException errors related to payload size limit exceeded, as these errors are not retryable.
1 parent b042739 commit 810647f

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/aws_durable_execution_sdk_python/exceptions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,14 @@ def from_exception(cls, exception: Exception) -> CheckpointError:
170170
and (
171171
# is not InvalidParam => Execution
172172
(error.get("Code", "") or "") != "InvalidParameterValueException"
173-
# is not Invalid Token => Execution
174-
or not (error.get("Message") or "").startswith(
175-
"Invalid Checkpoint Token"
173+
or not (
174+
# is not Invalid Token => Execution
175+
(error.get("Message") or "").startswith("Invalid Checkpoint Token")
176+
or
177+
# is not Output Payload Too Large => Execution
178+
(error.get("Message") or "").startswith(
179+
"STEP output payload size must be less than or equal to"
180+
)
176181
)
177182
)
178183
):

tests/exceptions_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ def test_checkpoint_error_classification_invalid_token_invocation():
7070
assert not result.is_retriable()
7171

7272

73+
def test_checkpoint_error_classification_payload_size_exceeded_invocation():
74+
"""Test 4xx InvalidParameterValueException with STEP output payload size limit exceeded is invocation error."""
75+
error_response = {
76+
"Error": {
77+
"Code": "InvalidParameterValueException",
78+
"Message": "STEP output payload size must be less than or equal to 262144 bytes.",
79+
},
80+
"ResponseMetadata": {"HTTPStatusCode": 400},
81+
}
82+
client_error = ClientError(error_response, "Checkpoint")
83+
84+
result = CheckpointError.from_exception(client_error)
85+
86+
assert result.error_category == CheckpointErrorCategory.INVOCATION
87+
assert not result.is_retriable()
88+
89+
7390
def test_checkpoint_error_classification_other_4xx_execution():
7491
"""Test other 4xx errors are execution errors."""
7592
error_response = {

0 commit comments

Comments
 (0)