Skip to content

Ensure update input and responses are run through converters #478

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 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions temporalio/bridge/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ async def decode_activation(
val.metadata.clear()
val.metadata.update(new_payload.metadata)
val.data = new_payload.data
elif job.HasField("do_update"):
await _decode_payloads(job.do_update.input, codec)


async def encode_completion(
Expand Down Expand Up @@ -322,3 +324,8 @@ async def encode_completion(
)
for val in command.start_child_workflow_execution.memo.values():
await _encode_payload(val, codec)
elif command.HasField("update_response"):
if command.update_response.HasField("completed"):
await _encode_payload(command.update_response.completed, codec)
elif command.update_response.HasField("rejected"):
await codec.encode_failure(command.update_response.rejected)
3 changes: 2 additions & 1 deletion tests/worker/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,14 +1467,15 @@ async def decode(self, payloads: Sequence[Payload]) -> List[Payload]:
return list(wrapper.payloads)


async def test_workflow_with_codec(client: Client):
async def test_workflow_with_codec(client: Client, env: WorkflowEnvironment):
# Make client with this codec and run a couple of existing tests
config = client.config()
config["data_converter"] = DataConverter(payload_codec=SimpleCodec())
client = Client(**config)
await test_workflow_signal_and_query(client)
await test_workflow_signal_and_query_errors(client)
await test_workflow_simple_activity(client)
await test_workflow_update_handlers_happy(client, env)


class CustomWorkflowRunner(WorkflowRunner):
Expand Down