@@ -56,6 +56,11 @@ class Output:
56
56
value : str
57
57
58
58
59
+ @dataclass
60
+ class NonSerializableOutput :
61
+ callable : Callable [[], Any ] = lambda : None
62
+
63
+
59
64
@dataclass
60
65
class TestContext :
61
66
workflow_id : Optional [str ] = None
@@ -96,6 +101,7 @@ class MyService:
96
101
handler_error_internal : nexusrpc .Operation [Input , Output ]
97
102
operation_error_failed : nexusrpc .Operation [Input , Output ]
98
103
idempotency_check : nexusrpc .Operation [None , Output ]
104
+ non_serializable_output : nexusrpc .Operation [Input , NonSerializableOutput ]
99
105
100
106
101
107
@workflow .defn
@@ -292,6 +298,12 @@ async def idempotency_check(
292
298
) -> Output :
293
299
return Output (value = f"request_id: { ctx .request_id } " )
294
300
301
+ @nexusrpc .handler .sync_operation_handler
302
+ async def non_serializable_output (
303
+ self , ctx : StartOperationContext , input : Input
304
+ ) -> NonSerializableOutput :
305
+ return NonSerializableOutput ()
306
+
295
307
296
308
@dataclass
297
309
class Failure :
@@ -653,6 +665,15 @@ class UnknownOperation(_FailureTestCase):
653
665
)
654
666
655
667
668
+ class NonSerializableOutputFailure (_FailureTestCase ):
669
+ operation = "non_serializable_output"
670
+ expected = UnsuccessfulResponse (
671
+ status_code = 500 ,
672
+ retryable_header = False ,
673
+ failure_message = "Object of type function is not JSON serializable" ,
674
+ )
675
+
676
+
656
677
@pytest .mark .parametrize (
657
678
"test_case" ,
658
679
[
@@ -687,6 +708,7 @@ async def test_start_operation_happy_path(
687
708
HandlerErrorInternal ,
688
709
UnknownService ,
689
710
UnknownOperation ,
711
+ NonSerializableOutputFailure ,
690
712
],
691
713
)
692
714
async def test_start_operation_protocol_level_failures (
0 commit comments