Skip to content

Commit a01993f

Browse files
committed
Address v1 status review feedback
Expose failed orchestration messages through the compatibility output property, reuse that projection in JSON output, clarify the shim documentation, and strengthen delegation assertions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ff9faf2d-e79a-4309-8a67-5d455e4dd7bd
1 parent f2ad8f5 commit a01993f

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

azure-functions-durable/azure/durable_functions/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,9 @@ async def get_status(
266266
267267
The ``show_history`` and ``show_history_output`` flags have no
268268
equivalent in durabletask and are ignored. Payloads are fetched to
269-
preserve the v1 output and custom-status fields; ``show_input`` controls
270-
whether the compatibility wrapper exposes the input.
269+
preserve the v1 output, custom-status, and failure-detail fields;
270+
``show_input`` controls whether the compatibility wrapper exposes the
271+
input.
271272
"""
272273
state = await self.get_orchestration_state(instance_id, fetch_payloads=True)
273274
return DurableOrchestrationStatus.from_orchestration_state(

azure-functions-durable/azure/durable_functions/internal/compat/durable_orchestration_status.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ def input_(self) -> Any:
116116

117117
@property
118118
def output(self) -> Any:
119-
"""Get the (deserialized) output of the orchestration instance."""
119+
"""Get the output or failure message of the orchestration instance."""
120120
if self._state is None:
121121
return None
122-
return self._raw_payload(self._state.serialized_output)
122+
output = self._raw_payload(self._state.serialized_output)
123+
if output is not None:
124+
return output
125+
failure = self._state.failure_details
126+
return failure.message if failure is not None else None
123127

124128
@property
125129
def runtime_status(self) -> Optional[OrchestrationRuntimeStatus]:
@@ -163,19 +167,9 @@ def to_json(self) -> dict[str, Any]:
163167
result["createdTime"] = self._format_datetime(self.created_time)
164168
if self.last_updated_time is not None:
165169
result["lastUpdatedTime"] = self._format_datetime(self.last_updated_time)
166-
output = self._raw_payload(
167-
self._state.serialized_output if self._state is not None else None)
170+
output = self.output
168171
if output is not None:
169172
result["output"] = output
170-
elif self._state is not None:
171-
# A failed orchestration carries its error in ``failure_details``
172-
# rather than ``serialized_output``; surface it under ``output``
173-
# (matching v1, where the failure message was returned through the
174-
# status output) so the error is not dropped from the payload.
175-
failure = getattr(self._state, "failure_details", None)
176-
failure_message = getattr(failure, "message", None) if failure is not None else None
177-
if failure_message:
178-
result["output"] = failure_message
179173
input_ = self.input_
180174
if input_ is not None:
181175
result["input"] = input_

tests/azure-functions-durable/test_client_compat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ async def test_get_status_all_delegates():
198198
new=AsyncMock(return_value=[])) as mock:
199199
with pytest.warns(DeprecationWarning):
200200
await client.get_status_all()
201+
mock.assert_awaited_once()
201202
query = mock.await_args.args[0]
202203
assert query.fetch_inputs_and_outputs is True
203204
finally:
@@ -316,6 +317,7 @@ async def test_get_status_by_maps_statuses():
316317
with pytest.warns(DeprecationWarning):
317318
await client.get_status_by(
318319
runtime_status=[df.OrchestrationRuntimeStatus.Running])
320+
mock.assert_awaited_once()
319321
query = mock.await_args.args[0]
320322
assert query.runtime_status == [OrchestrationStatus.RUNNING]
321323
assert query.fetch_inputs_and_outputs is True
@@ -582,6 +584,7 @@ async def test_get_status_failed_preserves_failure_output():
582584
new=AsyncMock(return_value=state)):
583585
with pytest.warns(DeprecationWarning):
584586
status = await client.get_status("abc")
587+
assert status.output == "boom"
585588
status_json = status.to_json()
586589
assert status_json["runtimeStatus"] == "Failed"
587590
assert status_json["output"] == "boom"

0 commit comments

Comments
 (0)