From 3808da237dae5bf316d8cd89c9f945e1b6777262 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 19 Dec 2024 09:40:40 -0500 Subject: [PATCH] Error on constructing start operation with invalid conflict policy --- temporalio/client.py | 2 ++ tests/worker/test_update_with_start.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/temporalio/client.py b/temporalio/client.py index 4b1c561d..52129e2c 100644 --- a/temporalio/client.py +++ b/temporalio/client.py @@ -2615,6 +2615,8 @@ def __init__( name, result_type_from_run_fn = ( temporalio.workflow._Definition.get_name_and_result_type(workflow) ) + if id_conflict_policy == temporalio.common.WorkflowIDConflictPolicy.UNSPECIFIED: + raise ValueError("WorkflowIDConflictPolicy is required") self._start_workflow_input = UpdateWithStartStartWorkflowInput( workflow=name, diff --git a/tests/worker/test_update_with_start.py b/tests/worker/test_update_with_start.py index 7c169352..160590e3 100644 --- a/tests/worker/test_update_with_start.py +++ b/tests/worker/test_update_with_start.py @@ -496,3 +496,22 @@ async def test_update_with_start_client_outbound_interceptor( wf_handle = await start_op.workflow_handle() assert await wf_handle.result() == "intercepted-workflow-arg" + + +def test_with_start_workflow_operation_requires_conflict_policy(): + with pytest.raises(ValueError): + WithStartWorkflowOperation( + WorkflowForUpdateWithStartTest.run, + 0, + id="wid-1", + id_conflict_policy=WorkflowIDConflictPolicy.UNSPECIFIED, + task_queue="test-queue", + ) + + with pytest.raises(TypeError): + WithStartWorkflowOperation( # type: ignore + WorkflowForUpdateWithStartTest.run, + 0, + id="wid-1", + task_queue="test-queue", + )