-
Notifications
You must be signed in to change notification settings - Fork 141
feat(sdk): 💥 add typed child workflow handle #1182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b9d6d93
refactor: move UntypedWorkflow from client to common crate
chris-olszewski 72abc25
feat(sdk): add ChildWorkflowExecutionError type
chris-olszewski 289d003
feat(sdk): typed child workflow API
chris-olszewski abbc3d4
update sdk readme
chris-olszewski 551657d
remove duped test
chris-olszewski 003b403
fix: avoid panic from child workflow payload converter failure
chris-olszewski 7704d7d
fix: avoid nested result for child workflow signal
chris-olszewski 1ab1be5
test: regression test for child cancel seq
chris-olszewski d3c65f6
fix: preexisting bugs claude found
chris-olszewski e822903
test: failing child workflow tests
chris-olszewski 92cfdf2
fix: handle missing child wfl result, issue correct cancel cmd
chris-olszewski 7f19656
pr feedback
chris-olszewski b9b2fa1
remove faulty comment
chris-olszewski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Both
UntypedWorkflow::Input = RawValueserialization andUntypedWorkflow::Output = RawValuedeserialization always returnWrongEncodingwhen the worker is configured withPayloadConverter::serde_json()directly (not the default composite converter). Fix: addas_serdeandfrom_serdeoverrides toRawValue'sTemporalSerializable/TemporalDeserializableimpls indata_converters.rs.Extended reasoning...
What the bug is and how it manifests
RawValuemanually implementsTemporalSerializable(overridingto_payload/to_payloads) andTemporalDeserializable(overridingfrom_payload/from_payloads), but does NOT overrideas_serde()orfrom_serde(). SinceRawValuederives onlyClone, Debug, Default— notserde::Serializeorserde::Deserialize— the blanket impls for those traits do not apply. Both trait defaults unconditionally returnErr(PayloadConversionError::WrongEncoding). As a result, any worker usingPayloadConverter::serde_json()directly will fail everyUntypedWorkflowchild workflow interaction.The specific code paths that trigger it
For input serialization (
as_serdeside):BaseWorkflowContext::child_workflowcallspayload_converter.to_payloads::<RawValue>(&ctx, &input). UnderPayloadConverter::Serde,GenericPayloadConverter::to_payloads::<RawValue>takes the non-()branch (data_converters.rs~465–472) and callsval.as_serde()?. BecauseRawValuedoes not overrideas_serde(), this falls back to the trait default and immediately returnsErr(WrongEncoding), causingChildWorkflowStartFut::eager(...)to be returned before any command is sent to Core — the child is never started.For output deserialization (
from_serdeside):ChildWorkflowFut::poll(new code introduced by this PR) callspayload_converter.from_payloads::<Output>(&ctx, payloads)whereOutput = RawValue. UnderPayloadConverter::Serde,GenericPayloadConverter::from_payloads::<RawValue>requirespayloads.len() == 1then callsT::from_serde(pc.as_ref(), context, payload)(data_converters.rs:503–507).RawValue::from_serdefalls back to the default returningErr(WrongEncoding), sostarted.result().awaitalways yieldsErr(ChildWorkflowExecutionError::Serialization(WrongEncoding))even for successfully-completed child workflows.Why existing code does not prevent it
The default
PayloadConverterisComposite([UseWrappers, serde_json]). TheUseWrappersarm callsT::to_payloads(val, context)andT::from_payloads(context, payloads)directly — bypassingas_serde/from_serdeentirely — and these are correctly overridden onRawValue. So the default converter works fine, and all existing integration tests (including the newuntyped_child_workflow_happy_path) pass because they all use the default converter.Why this is introduced by the PR (addressing the pre-existing refutation)
One verifier argued that
as_serdewas pre-existing sinceUntypedWorkflow::Input = RawValueexisted before incrates/client/src/workflow_handle.rs. However, the critical distinction is that the oldChildWorkflowOptionsacceptedVec<Payload>for itsinputfield, passing them directly to the proto command without going through any type-based serialization. This PR changes the API to route child workflow input throughpayload_converter.to_payloads::<WD::Input>(), which is the new code path that first exposes theas_serdegap forRawValuein workflow execution. Thefrom_serdegap for the result path (ChildWorkflowFut) is unambiguously new code introduced entirely by this PR.Impact and fix
Any user who constructs
DataConverter::new(PayloadConverter::serde_json(), ...)— a documented public API — and usesUntypedWorkflowas a child workflow will getSerialization(WrongEncoding)on every start or result await. Fix: indata_converters.rs, addfn as_serde(&self) -> Result<...> { ... }toRawValue'sTemporalSerializableimpl (returning an appropriate serde representation of its payload bytes, or redirecting toto_payloads) and addfn from_serde(...) -> Result<Self, ...> { Ok(RawValue { payloads: vec![payload] }) }to itsTemporalDeserializableimpl.Step-by-step proof
DataConverter::new(PayloadConverter::serde_json(), ...).ctx.child_workflow(UntypedWorkflow::new("my-wf"), RawValue::new(vec![]), opts).await.BaseWorkflowContext::child_workflowcallspayload_converter.to_payloads::<RawValue>(&ctx, &input).PayloadConverter::Serdearm:RawValueis not(), soval.as_serde()?is called.RawValue::as_serde()returnsErr(WrongEncoding)(trait default).child_workflow()returnsChildWorkflowStartFut::Errored(Serialization(WrongEncoding))..awaiton the future immediately yieldsErr(ChildWorkflowExecutionError::Serialization(WrongEncoding))— child never starts. For the deserialization path: even if the child completes successfully, step 3 instead callsfrom_payloads::<RawValue>which callsRawValue::from_serde(...)→Err(WrongEncoding)→Err(ChildWorkflowExecutionError::Serialization(WrongEncoding)).