diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json index 1e41f9a76a0..a94bf3829d0 100644 --- a/basedpyright-code-budget.json +++ b/basedpyright-code-budget.json @@ -84,7 +84,7 @@ "limit": 56 }, "reportPrivateUsage": { - "limit": 1803 + "limit": 1802 }, "reportRedeclaration": { "limit": 8 diff --git a/ruff-strict-budget.json b/ruff-strict-budget.json index 50441834059..babf1d367d0 100644 --- a/ruff-strict-budget.json +++ b/ruff-strict-budget.json @@ -57,7 +57,7 @@ "limit": 3 }, "BLE001": { - "limit": 2914 + "limit": 2913 }, "C401": { "limit": 8 diff --git a/test-quality-budget.json b/test-quality-budget.json index 74028b66e40..c140f27aeab 100644 --- a/test-quality-budget.json +++ b/test-quality-budget.json @@ -3,7 +3,7 @@ "limit": 736 }, "TQ002": { - "limit": 738 + "limit": 736 }, "TQ003": { "limit": 62 @@ -21,6 +21,6 @@ "limit": 117 }, "TQ008": { - "limit": 11097 + "limit": 11078 } } diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py index f323e6214da..f520e5cf243 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py @@ -22,6 +22,7 @@ from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( LITELLM_PASS_THROUGH_CUSTOM_BODY_STATE_KEY, HttpPassThroughEndpointHelpers, InitPassThroughEndpointHelpers, + _dispatch_passthrough_dynamic_failure, _registered_pass_through_routes, create_pass_through_route, initialize_pass_through_endpoints, @@ -5490,8 +5491,16 @@ async def test_websocket_passthrough_initializes_team_logging_before_dispatch(): @pytest.mark.asyncio -async def test_pass_through_request_dispatches_team_failure_callback_once_for_upstream_error(): - failure_dispatcher = AsyncMock() +async def test_pass_through_request_dispatches_real_team_failure_callback_once_for_upstream_error(): + class RecordingFailureCallback(CustomLogger): + def __init__(self) -> None: + super().__init__() + self.events = [] + + async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time) -> None: + self.events.append(kwargs) + + callback = RecordingFailureCallback() upstream_transport = _FakeUpstreamTransport( status_code=403, headers={"content-type": "application/json"}, @@ -5508,28 +5517,34 @@ async def test_pass_through_request_dispatches_team_failure_callback_once_for_up } ) dependencies = _PassThroughRequestDependencies({}) + team_key = _team_scoped_langfuse_otel_key(callback_type="failure") try: - response = await pass_through_request( - request=request, - target="http://upstream.test/v1/chat/completions", - custom_headers={}, - user_api_key_dict=_team_scoped_langfuse_otel_key(callback_type="failure"), - forward_headers=True, - proxy_config=MagicMock(), - dynamic_failure_dispatcher=failure_dispatcher, - **dependencies.kwargs(), - ) + with ( + patch("litellm.proxy.proxy_server.general_settings", {"litellm_key_header_name": "x-custom-litellm-key"}), + patch( + "litellm.litellm_core_utils.litellm_logging._init_custom_logger_compatible_class", + return_value=callback, + ), + ): + response = await pass_through_request( + request=request, + target="http://upstream.test/v1/chat/completions", + custom_headers={}, + user_api_key_dict=team_key, + forward_headers=True, + proxy_config=MagicMock(), + dynamic_failure_dispatcher=_dispatch_passthrough_dynamic_failure, + **dependencies.kwargs(), + ) assert response.status_code == 403 assert json.loads(response.body) == {"error": "upstream denied"} - dispatched_logging_obj, dispatched_exception, dispatched_traceback = failure_dispatcher.await_args.args - assert dispatched_exception.status_code == 403 - assert isinstance(dispatched_traceback, str) - assert dispatched_logging_obj.model_call_details["additional_args"]["headers"] == { + assert len(callback.events) == 1 + assert callback.events[0]["additional_args"]["headers"] == { "authorization": "***REDACTED***", "x-api-key": "***REDACTED***", - "x-custom-litellm-key": "virtual-key-secret", + "x-custom-litellm-key": "***REDACTED***", "x-request-id": "request-123", } assert upstream_transport.request is not None diff --git a/type-discipline-budget.json b/type-discipline-budget.json index 36d7e51fb6a..173dc1b294b 100644 --- a/type-discipline-budget.json +++ b/type-discipline-budget.json @@ -3,7 +3,7 @@ "limit": 22733 }, "LIT002": { - "limit": 26859 + "limit": 26858 }, "LIT003": { "limit": 269 @@ -27,7 +27,7 @@ "limit": 0 }, "LIT010": { - "limit": 16612 + "limit": 16611 }, "LIT011": { "limit": 5583