Skip to content

Commit 3025b34

Browse files
committed
fix: use exact Invalid checkpoint token match
Match the backend error prefix case-sensitively and restore the single-unit test description preferred in review.
1 parent cf53cef commit 3025b34

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python/exceptions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
TOO_MANY_REQUESTS_ERROR: int = 429
1414
SERVICE_ERROR: int = 500
1515
INVALID_PARAMETER_VALUE_EXCEPTION: str = "InvalidParameterValueException"
16-
INVALID_CHECKPOINT_TOKEN_PREFIX: str = "invalid checkpoint token"
16+
INVALID_CHECKPOINT_TOKEN_PREFIX: str = "Invalid checkpoint token"
1717

1818
# Non-retryable customer error codes that arrive as non-4xx (e.g. HTTP 502) from Lambda.
1919
# Unlike typical 5xx errors, these require customer intervention (e.g., fixing
@@ -162,7 +162,7 @@ def _classify_error_category(
162162
These arrive as HTTP 502 but require customer intervention to fix.
163163
- 4xx errors → EXECUTION, except:
164164
- 429 (TooManyRequests) → INVOCATION (throttling is transient)
165-
- InvalidParameterValueException with "Invalid checkpoint token" (case-insensitive) → INVOCATION
165+
- InvalidParameterValueException with "Invalid checkpoint token" (exact match) → INVOCATION
166166
(stale token from a concurrent checkpoint; next invocation gets a fresh token)
167167
- 5xx, network errors → INVOCATION
168168
"""
@@ -180,9 +180,9 @@ def _classify_error_category(
180180
and error
181181
and not (
182182
(error.get("Code") or "") == INVALID_PARAMETER_VALUE_EXCEPTION
183-
and (error.get("Message") or "")
184-
.casefold()
185-
.startswith(INVALID_CHECKPOINT_TOKEN_PREFIX)
183+
and (error.get("Message") or "").startswith(
184+
INVALID_CHECKPOINT_TOKEN_PREFIX
185+
)
186186
)
187187
):
188188
return DurableApiErrorCategory.EXECUTION

packages/aws-durable-execution-sdk-python/tests/exceptions_test.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,12 @@ def test_checkpoint_error():
6565
assert error.termination_reason == TerminationReason.CHECKPOINT_FAILED
6666

6767

68-
@pytest.mark.parametrize(
69-
"message",
70-
[
71-
"Invalid checkpoint token: token expired",
72-
"Invalid Checkpoint Token: token expired",
73-
],
74-
)
75-
def test_checkpoint_error_classification_invalid_token_invocation(message: str):
76-
"""Service emits lowercase 'checkpoint token'; match case-insensitively as invocation."""
68+
def test_checkpoint_error_classification_invalid_token_invocation():
69+
"""Test 4xx InvalidParameterValueException with "Invalid checkpoint token" error message is an invocation error."""
7770
error_response = {
7871
"Error": {
7972
"Code": "InvalidParameterValueException",
80-
"Message": message,
73+
"Message": "Invalid checkpoint token: token expired",
8174
},
8275
"ResponseMetadata": {"HTTPStatusCode": 400},
8376
}

0 commit comments

Comments
 (0)