From deb1751c4be4e9d9c963a0d475755af37ef76429 Mon Sep 17 00:00:00 2001 From: Quinn Sinclair Date: Wed, 19 Nov 2025 19:28:40 +0000 Subject: [PATCH 1/3] allow empty operations list --- .../execution.py | 23 +++++++++++++------ tests/execution_test.py | 13 +++++++---- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/aws_durable_execution_sdk_python/execution.py b/src/aws_durable_execution_sdk_python/execution.py index 5b31d53..0d8ab12 100644 --- a/src/aws_durable_execution_sdk_python/execution.py +++ b/src/aws_durable_execution_sdk_python/execution.py @@ -58,10 +58,15 @@ def from_dict(input_dict: MutableMapping[str, Any]) -> InitialExecutionState: next_marker=input_dict.get("NextMarker", ""), ) - def get_execution_operation(self) -> Operation: + def get_execution_operation(self) -> Operation | None: if len(self.operations) < 1: + # Due to payload size limitations we may have an empty operations list. + # This will only happen when loading the initial page of results and is + # expected behaviour. We don't fail, but instead return None + # as the execution operation does not exist msg: str = "No durable operations found in initial execution state." - raise DurableExecutionsError(msg) + logger.debug(msg) + return None candidate = self.operations[0] if candidate.operation_type is not OperationType.EXECUTION: @@ -71,11 +76,15 @@ def get_execution_operation(self) -> Operation: return candidate def get_input_payload(self) -> str | None: - # TODO: are these None checks necessary? i.e will there always be execution_details with input_payload - if execution_details := self.get_execution_operation().execution_details: - return execution_details.input_payload - - return None + # It is possible that backend will not provide an execution operation + # for the initial page of results. + if not (operations := self.get_execution_operation()): + return None + if not (execution_details := operations.execution_details): + return None + if not (input_payload := execution_details.input_payload): + return None + return input_payload def to_dict(self) -> MutableMapping[str, Any]: return { diff --git a/tests/execution_test.py b/tests/execution_test.py index 57c83c7..4d11298 100644 --- a/tests/execution_test.py +++ b/tests/execution_test.py @@ -788,13 +788,16 @@ def test_handler(event: Any, context: DurableContext) -> dict: def test_initial_execution_state_get_execution_operation_no_operations(): - """Test get_execution_operation raises error when no operations exist.""" + """Test get_execution_operation logs debug and returns None when no operations exist.""" state = InitialExecutionState(operations=[], next_marker="") - with pytest.raises( - Exception, match="No durable operations found in initial execution state" - ): - state.get_execution_operation() + with patch("aws_durable_execution_sdk_python.execution.logger") as mock_logger: + result = state.get_execution_operation() + + assert result is None + mock_logger.debug.assert_called_once_with( + "No durable operations found in initial execution state." + ) def test_initial_execution_state_get_execution_operation_wrong_type(): From 21740444e3badd899a30fa08a0da80bb4d564182 Mon Sep 17 00:00:00 2001 From: Astraea Quinn S <52372765+PartiallyUntyped@users.noreply.github.com> Date: Wed, 19 Nov 2025 19:35:21 +0000 Subject: [PATCH 2/3] Update src/aws_durable_execution_sdk_python/execution.py --- src/aws_durable_execution_sdk_python/execution.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/aws_durable_execution_sdk_python/execution.py b/src/aws_durable_execution_sdk_python/execution.py index 0d8ab12..6ee5ccf 100644 --- a/src/aws_durable_execution_sdk_python/execution.py +++ b/src/aws_durable_execution_sdk_python/execution.py @@ -82,9 +82,7 @@ def get_input_payload(self) -> str | None: return None if not (execution_details := operations.execution_details): return None - if not (input_payload := execution_details.input_payload): - return None - return input_payload + return execution_details.input_payload def to_dict(self) -> MutableMapping[str, Any]: return { From 5645cb92eb627366a482383223946420223c000c Mon Sep 17 00:00:00 2001 From: Astraea Quinn S <52372765+PartiallyUntyped@users.noreply.github.com> Date: Thu, 20 Nov 2025 02:14:01 +0000 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Leandro Damascena --- src/aws_durable_execution_sdk_python/execution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aws_durable_execution_sdk_python/execution.py b/src/aws_durable_execution_sdk_python/execution.py index 6ee5ccf..a31e227 100644 --- a/src/aws_durable_execution_sdk_python/execution.py +++ b/src/aws_durable_execution_sdk_python/execution.py @@ -59,7 +59,7 @@ def from_dict(input_dict: MutableMapping[str, Any]) -> InitialExecutionState: ) def get_execution_operation(self) -> Operation | None: - if len(self.operations) < 1: + if not self.operations: # Due to payload size limitations we may have an empty operations list. # This will only happen when loading the initial page of results and is # expected behaviour. We don't fail, but instead return None