Skip to content

Commit 250272b

Browse files
committed
Emit a nice message for negative values
1 parent e9f6b03 commit 250272b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

temporalio/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8449,6 +8449,8 @@ async def start_activity(self, input: StartActivityInput) -> ActivityHandle[Any]
84498449
raise ValueError(
84508450
"Activity must have start_to_close_timeout or schedule_to_close_timeout"
84518451
)
8452+
if input.start_delay is not None and input.start_delay < timedelta(0):
8453+
raise ValueError("start_delay must be non-negative")
84528454
req = await self._build_start_activity_execution_request(input)
84538455

84548456
resp: temporalio.api.workflowservice.v1.StartActivityExecutionResponse

tests/test_activity.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,18 @@ async def test_count_activities_calls_interceptor(
416416
assert call.query == query
417417

418418

419+
async def test_start_activity_rejects_negative_start_delay(client: Client):
420+
with pytest.raises(ValueError, match="start_delay must be non-negative"):
421+
await client.start_activity(
422+
increment,
423+
args=(1,),
424+
id=str(uuid.uuid4()),
425+
task_queue=str(uuid.uuid4()),
426+
start_to_close_timeout=timedelta(seconds=5),
427+
start_delay=timedelta(seconds=-1),
428+
)
429+
430+
419431
async def test_get_result(client: Client, env: WorkflowEnvironment):
420432
if env.supports_time_skipping:
421433
pytest.skip(

0 commit comments

Comments
 (0)