diff --git a/litellm/llms/bedrock/batches/handler.py b/litellm/llms/bedrock/batches/handler.py index c071f331337..8c100a85a71 100644 --- a/litellm/llms/bedrock/batches/handler.py +++ b/litellm/llms/bedrock/batches/handler.py @@ -267,10 +267,16 @@ class BedrockBatchesHandler: response = client.get_model_invocation_job(jobIdentifier=batch_id) if logging_obj is not None: + # boto3 returns native datetime objects for time fields + # (submitTime, endTime, …) and in ResponseMetadata. The + # logging post_call path calls json.dumps() on dict responses, + # which chokes on datetime — so we serialize with default=str. + import json as _json + logging_obj.post_call( input=batch_id, api_key="", - original_response=response, + original_response=_json.dumps(response, default=str), additional_args={"complete_input_dict": {"jobIdentifier": batch_id}}, ) diff --git a/tests/test_litellm/llms/bedrock/batches/test_handler.py b/tests/test_litellm/llms/bedrock/batches/test_handler.py index 18780ccce0f..1b795349548 100644 --- a/tests/test_litellm/llms/bedrock/batches/test_handler.py +++ b/tests/test_litellm/llms/bedrock/batches/test_handler.py @@ -300,7 +300,11 @@ def test_logging_obj_pre_and_post_call_invoked(patched_boto3): post_kwargs = logging_obj.post_call.call_args.kwargs assert post_kwargs["input"] == JOB_ARN - assert post_kwargs["original_response"]["jobArn"] == JOB_ARN + # original_response is JSON-serialized (str) because boto3 returns + # datetime objects that json.dumps() cannot handle natively. + import json + parsed = json.loads(post_kwargs["original_response"]) + assert parsed["jobArn"] == JOB_ARN def test_missing_boto3_raises_helpful_import_error():