Skip to content

Commit 10036b2

Browse files
authored
fix: handle query parameters in GetDurableExecutionHistory properly (#125)
1 parent ccef0de commit 10036b2

File tree

2 files changed

+95
-7
lines changed

2 files changed

+95
-7
lines changed

src/aws_durable_execution_sdk_python_testing/web/handlers.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,16 +459,24 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
459459
history_route = cast(GetDurableExecutionHistoryRoute, parsed_route)
460460
execution_arn: str = history_route.arn
461461

462-
max_results: str | None = self._parse_query_param(request, "maxResults")
463-
next_token: str | None = self._parse_query_param(request, "nextToken")
462+
max_items: str | None = self._parse_query_param(request, "MaxItems")
463+
marker: str | None = self._parse_query_param(request, "Marker")
464+
include_execution_data_str: str | None = self._parse_query_param(
465+
request, "IncludeExecutionData"
466+
)
467+
include_execution_data: bool = (
468+
include_execution_data_str == "true"
469+
if include_execution_data_str
470+
else False
471+
)
464472

465473
history_response: GetDurableExecutionHistoryResponse = (
466474
self.executor.get_execution_history(
467475
execution_arn,
468-
include_execution_data=False,
476+
include_execution_data=include_execution_data,
469477
reverse_order=False,
470-
marker=next_token,
471-
max_items=int(max_results) if max_results else None,
478+
marker=marker,
479+
max_items=int(max_items) if max_items else None,
472480
)
473481
)
474482

tests/web/handlers_test.py

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ def test_get_durable_execution_history_handler_success():
11271127
method="GET",
11281128
path=typed_route,
11291129
headers={},
1130-
query_params={"maxResults": ["10"], "nextToken": ["token-123"]},
1130+
query_params={"MaxItems": ["10"], "Marker": ["token-123"]},
11311131
body={},
11321132
)
11331133

@@ -1203,7 +1203,7 @@ def test_get_durable_execution_history_handler_with_query_params():
12031203
method="GET",
12041204
path=typed_route,
12051205
headers={},
1206-
query_params={"maxResults": ["25"]},
1206+
query_params={"MaxItems": ["25"]},
12071207
body={},
12081208
)
12091209

@@ -1223,6 +1223,86 @@ def test_get_durable_execution_history_handler_with_query_params():
12231223
)
12241224

12251225

1226+
def test_get_durable_execution_history_handler_with_include_execution_data():
1227+
"""Test GetDurableExecutionHistoryHandler with IncludeExecutionData parameter."""
1228+
1229+
executor = Mock()
1230+
handler = GetDurableExecutionHistoryHandler(executor)
1231+
1232+
# Mock the executor response
1233+
mock_response = GetDurableExecutionHistoryResponse(events=[], next_marker=None)
1234+
executor.get_execution_history.return_value = mock_response
1235+
1236+
# Create strongly-typed route using Router
1237+
router = Router()
1238+
typed_route = router.find_route(
1239+
"/2025-12-01/durable-executions/test-arn/history", "GET"
1240+
)
1241+
1242+
request = HTTPRequest(
1243+
method="GET",
1244+
path=typed_route,
1245+
headers={},
1246+
query_params={"IncludeExecutionData": ["true"], "MaxItems": ["1000"]},
1247+
body={},
1248+
)
1249+
1250+
response = handler.handle(typed_route, request)
1251+
1252+
# Verify response
1253+
assert response.status_code == 200
1254+
assert response.body == {"Events": []}
1255+
1256+
# Verify executor was called with include_execution_data=True
1257+
executor.get_execution_history.assert_called_once_with(
1258+
"test-arn",
1259+
include_execution_data=True,
1260+
reverse_order=False,
1261+
marker=None,
1262+
max_items=1000,
1263+
)
1264+
1265+
1266+
def test_get_durable_execution_history_handler_with_include_execution_data_false():
1267+
"""Test GetDurableExecutionHistoryHandler with IncludeExecutionData=false."""
1268+
1269+
executor = Mock()
1270+
handler = GetDurableExecutionHistoryHandler(executor)
1271+
1272+
# Mock the executor response
1273+
mock_response = GetDurableExecutionHistoryResponse(events=[], next_marker=None)
1274+
executor.get_execution_history.return_value = mock_response
1275+
1276+
# Create strongly-typed route using Router
1277+
router = Router()
1278+
typed_route = router.find_route(
1279+
"/2025-12-01/durable-executions/test-arn/history", "GET"
1280+
)
1281+
1282+
request = HTTPRequest(
1283+
method="GET",
1284+
path=typed_route,
1285+
headers={},
1286+
query_params={"IncludeExecutionData": ["false"]},
1287+
body={},
1288+
)
1289+
1290+
response = handler.handle(typed_route, request)
1291+
1292+
# Verify response
1293+
assert response.status_code == 200
1294+
assert response.body == {"Events": []}
1295+
1296+
# Verify executor was called with include_execution_data=False
1297+
executor.get_execution_history.assert_called_once_with(
1298+
"test-arn",
1299+
include_execution_data=False,
1300+
reverse_order=False,
1301+
marker=None,
1302+
max_items=None,
1303+
)
1304+
1305+
12261306
def test_list_durable_executions_handler_success():
12271307
"""Test ListDurableExecutionsHandler with successful execution listing."""
12281308
executor = Mock()

0 commit comments

Comments
 (0)