@@ -58,10 +58,15 @@ def from_dict(input_dict: MutableMapping[str, Any]) -> InitialExecutionState:
5858 next_marker = input_dict .get ("NextMarker" , "" ),
5959 )
6060
61- def get_execution_operation (self ) -> Operation :
61+ def get_execution_operation (self ) -> Operation | None :
6262 if len (self .operations ) < 1 :
63+ # Due to payload size limitations we may have an empty operations list.
64+ # This will only happen when loading the initial page of results and is
65+ # expected behaviour. We don't fail, but instead return None
66+ # as the execution operation does not exist
6367 msg : str = "No durable operations found in initial execution state."
64- raise DurableExecutionsError (msg )
68+ logger .debug (msg )
69+ return None
6570
6671 candidate = self .operations [0 ]
6772 if candidate .operation_type is not OperationType .EXECUTION :
@@ -71,11 +76,15 @@ def get_execution_operation(self) -> Operation:
7176 return candidate
7277
7378 def get_input_payload (self ) -> str | None :
74- # TODO: are these None checks necessary? i.e will there always be execution_details with input_payload
75- if execution_details := self .get_execution_operation ().execution_details :
76- return execution_details .input_payload
77-
78- return None
79+ # It is possible that backend will not provide an execution operation
80+ # for the initial page of results.
81+ if not (operations := self .get_execution_operation ()):
82+ return None
83+ if not (execution_details := operations .execution_details ):
84+ return None
85+ if not (input_payload := execution_details .input_payload ):
86+ return None
87+ return input_payload
7988
8089 def to_dict (self ) -> MutableMapping [str , Any ]:
8190 return {
0 commit comments