Skip to content

Commit 7532a7f

Browse files
[cross-repo from server#333] Conformance finding: child workflow result is null in parent (#131)
1 parent 669f69d commit 7532a7f

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88

99
### Fixed
10+
- Python parent workflows now decode successful child workflow completions from
11+
the server's documented `ChildRunCompleted.output` history payload, while
12+
still accepting the older `result` alias. This prevents completed child
13+
workflow returns from replaying as `None`.
1014
- Condition-wait replay now binds signals that arrive during a leased
1115
workflow task to the next recorded wait when the server history records
1216
those signals before the task's `ConditionWaitOpened` row. This avoids

src/durable_workflow/workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,8 +1419,10 @@ def _decode_history_result(
14191419
external_storage_cache: ExternalPayloadCache | None = None,
14201420
) -> Any:
14211421
codec = payload.get("payload_codec") or fallback_codec
1422+
value = payload["result"] if "result" in payload else payload.get("output")
1423+
14221424
return serializer.decode_envelope(
1423-
payload.get("result"),
1425+
value,
14241426
codec=codec,
14251427
external_storage=external_storage,
14261428
external_storage_cache=external_storage_cache,

tests/test_replay.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,16 @@ def test_first_replay_starts_child(self) -> None:
925925
assert cmd.workflow_type == "sub-workflow"
926926
assert cmd.arguments == ["alice"]
927927

928-
def test_child_completed(self) -> None:
929-
history = [{"event_type": "ChildRunCompleted", "payload": {"result": '"sub-result"'}}]
928+
@pytest.mark.parametrize(
929+
"payload",
930+
[
931+
{"output": '"sub-result"'},
932+
{"output": serializer.envelope("sub-result", codec="json")},
933+
{"result": '"sub-result"'},
934+
],
935+
)
936+
def test_child_completed(self, payload: dict[str, object]) -> None:
937+
history = [{"event_type": "ChildRunCompleted", "payload": payload}]
930938
outcome = replay(ChildWorkflow, history, ["alice"])
931939
assert len(outcome.commands) == 1
932940
cmd = outcome.commands[0]

0 commit comments

Comments
 (0)