3737)
3838from urllib .request import urlopen
3939
40+ import pydantic
4041from google .protobuf .timestamp_pb2 import Timestamp
4142from typing_extensions import Literal , Protocol , runtime_checkable
4243
@@ -5194,6 +5195,30 @@ async def run_scenario(
51945195 )
51955196
51965197
5198+ class Foo (pydantic .BaseModel ):
5199+ bar : str
5200+
5201+
5202+ @workflow .defn (failure_exception_types = [pydantic .ValidationError ])
5203+ class FailOnBadPydanticInputWorkflow :
5204+ @workflow .run
5205+ async def run (self , params : Foo ) -> None :
5206+ pass
5207+
5208+
5209+ async def test_workflow_fail_on_bad_pydantic_input (client : Client ):
5210+ async with new_worker (client , FailOnBadPydanticInputWorkflow ) as worker :
5211+ with pytest .raises (WorkflowFailureError ) as err :
5212+ await client .execute_workflow (
5213+ "FailOnBadPydanticInputWorkflow" ,
5214+ {"bar" : 123 }, # This should fail validation
5215+ id = f"wf-{ uuid .uuid4 ()} " ,
5216+ task_queue = worker .task_queue ,
5217+ )
5218+ assert isinstance (err .value .cause , ApplicationError )
5219+ assert "1 validation error for Foo" in err .value .cause .message
5220+
5221+
51975222@workflow .defn (failure_exception_types = [Exception ])
51985223class FailOnBadInputWorkflow :
51995224 @workflow .run
@@ -5211,7 +5236,7 @@ async def test_workflow_fail_on_bad_input(client: Client):
52115236 task_queue = worker .task_queue ,
52125237 )
52135238 assert isinstance (err .value .cause , ApplicationError )
5214- assert "Failed decoding arguments " in err .value .cause .message
5239+ assert "Expected value to be str, was <class 'int'> " in err .value .cause .message
52155240
52165241
52175242@workflow .defn
0 commit comments