@@ -612,3 +612,57 @@ def test_invoke_handler_default_config_no_tenant_id():
612612 chained_invoke_options = operation_update .to_dict ()["ChainedInvokeOptions" ]
613613 assert chained_invoke_options ["FunctionName" ] == "test_function"
614614 assert "TenantId" not in chained_invoke_options
615+
616+
617+ def test_invoke_handler_defaults_to_json_serdes ():
618+ """Test invoke_handler uses DEFAULT_JSON_SERDES when config has no serdes."""
619+ mock_state = Mock (spec = ExecutionState )
620+ mock_state .durable_execution_arn = "test_arn"
621+ mock_state .get_checkpoint_result .return_value = (
622+ CheckpointedResult .create_not_found ()
623+ )
624+
625+ config = InvokeConfig [dict , dict ](serdes_payload = None , serdes_result = None )
626+ payload = {"key" : "value" , "number" : 42 }
627+
628+ with pytest .raises (SuspendExecution ):
629+ invoke_handler (
630+ function_name = "test_function" ,
631+ payload = payload ,
632+ state = mock_state ,
633+ operation_identifier = OperationIdentifier ("invoke_json" , None , None ),
634+ config = config ,
635+ )
636+
637+ # Verify JSON serialization was used (not extended types)
638+ operation_update = mock_state .create_checkpoint .call_args [1 ]["operation_update" ]
639+ assert operation_update .payload == json .dumps (payload )
640+
641+
642+ def test_invoke_handler_result_defaults_to_json_serdes ():
643+ """Test invoke_handler uses DEFAULT_JSON_SERDES for result deserialization."""
644+ mock_state = Mock (spec = ExecutionState )
645+ mock_state .durable_execution_arn = "test_arn"
646+
647+ result_data = {"key" : "value" , "number" : 42 }
648+ operation = Operation (
649+ operation_id = "invoke_result_json" ,
650+ operation_type = OperationType .CHAINED_INVOKE ,
651+ status = OperationStatus .SUCCEEDED ,
652+ chained_invoke_details = ChainedInvokeDetails (result = json .dumps (result_data )),
653+ )
654+ mock_result = CheckpointedResult .create_from_operation (operation )
655+ mock_state .get_checkpoint_result .return_value = mock_result
656+
657+ config = InvokeConfig [dict , dict ](serdes_payload = None , serdes_result = None )
658+
659+ result = invoke_handler (
660+ function_name = "test_function" ,
661+ payload = {"input" : "data" },
662+ state = mock_state ,
663+ operation_identifier = OperationIdentifier ("invoke_result_json" , None , None ),
664+ config = config ,
665+ )
666+
667+ # Verify JSON deserialization was used (not extended types)
668+ assert result == result_data
0 commit comments