Skip to content

Commit e4017d7

Browse files
Normalize child workflow failure kind
1 parent c411083 commit e4017d7

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎src/durable_workflow/workflow.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ def _child_workflow_failed_from_payload(
22992299
return ChildWorkflowFailed(
23002300
message or "child workflow failed",
23012301
exception_class,
2302-
failure_kind=_optional_str(payload.get("failure_category")) or "child_workflow",
2302+
failure_kind="child_workflow",
23032303
child_workflow_run_id=child_workflow_run_id,
23042304
child_workflow_type=child_workflow_type,
23052305
)

‎tests/test_replay.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,34 @@ def test_child_failed_preserves_typed_details(self) -> None:
13931393
"child_workflow_type": "sub-workflow",
13941394
}
13951395

1396+
def test_child_failed_reports_parent_failure_kind_for_application_child(self) -> None:
1397+
history = [
1398+
{
1399+
"event_type": "ChildRunFailed",
1400+
"payload": {
1401+
"message": "planned typed child failure: typed-marker",
1402+
"exception_type": "PlannedChildFailure",
1403+
"exception_class": "smoke.PlannedChildFailure",
1404+
"failure_category": "application",
1405+
"child_workflow_run_id": "child-run-1",
1406+
"child_workflow_type": "sub-workflow",
1407+
},
1408+
},
1409+
]
1410+
1411+
outcome = replay(ChildWorkflowFailureDetailsWf, history, [])
1412+
1413+
assert len(outcome.commands) == 1
1414+
cmd = outcome.commands[0]
1415+
assert isinstance(cmd, CompleteWorkflow)
1416+
assert cmd.result == {
1417+
"message": "planned typed child failure: typed-marker",
1418+
"exception_class": "smoke.PlannedChildFailure",
1419+
"failure_kind": "child_workflow",
1420+
"child_workflow_run_id": "child-run-1",
1421+
"child_workflow_type": "sub-workflow",
1422+
}
1423+
13961424
def test_child_failed_prefers_nested_exception_class_over_type(self) -> None:
13971425
history = [
13981426
{

0 commit comments

Comments
 (0)