Skip to content

Commit f31f927

Browse files
authored
Ensure update input and responses are run through converters (#478)
1 parent 1cfdaa8 commit f31f927

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

temporalio/bridge/worker.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ async def decode_activation(
275275
val.metadata.clear()
276276
val.metadata.update(new_payload.metadata)
277277
val.data = new_payload.data
278+
elif job.HasField("do_update"):
279+
await _decode_payloads(job.do_update.input, codec)
278280

279281

280282
async def encode_completion(
@@ -322,3 +324,8 @@ async def encode_completion(
322324
)
323325
for val in command.start_child_workflow_execution.memo.values():
324326
await _encode_payload(val, codec)
327+
elif command.HasField("update_response"):
328+
if command.update_response.HasField("completed"):
329+
await _encode_payload(command.update_response.completed, codec)
330+
elif command.update_response.HasField("rejected"):
331+
await codec.encode_failure(command.update_response.rejected)

tests/worker/test_workflow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,14 +1467,15 @@ async def decode(self, payloads: Sequence[Payload]) -> List[Payload]:
14671467
return list(wrapper.payloads)
14681468

14691469

1470-
async def test_workflow_with_codec(client: Client):
1470+
async def test_workflow_with_codec(client: Client, env: WorkflowEnvironment):
14711471
# Make client with this codec and run a couple of existing tests
14721472
config = client.config()
14731473
config["data_converter"] = DataConverter(payload_codec=SimpleCodec())
14741474
client = Client(**config)
14751475
await test_workflow_signal_and_query(client)
14761476
await test_workflow_signal_and_query_errors(client)
14771477
await test_workflow_simple_activity(client)
1478+
await test_workflow_update_handlers_happy(client, env)
14781479

14791480

14801481
class CustomWorkflowRunner(WorkflowRunner):

0 commit comments

Comments
 (0)