From bdfb8d58476a0ee3fdecf59b1195a24b38e83187 Mon Sep 17 00:00:00 2001 From: yucheng Date: Mon, 2 Nov 2026 14:03:51 -0800 Subject: [PATCH] test(proxy): check the guardrail header size budget by its result --- .../test_pass_through_endpoints.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py b/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py index 2b0932fb8fd..1ee3ee6c0a9 100644 --- a/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py +++ b/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py @@ -13790,16 +13790,10 @@ class TestGuardrailResponseHeaders: assert headers == {"x-litellm-applied-policies": "tag-policy"} assert h11.Response(status_code=200, headers=[*headers.items()]).status_code == 200 - def test_guardrail_header_past_the_size_budget_is_left_out_without_scanning_its_characters(self): + def test_guardrail_header_past_the_size_budget_is_left_out(self): names: Final = [f"g{index}" for index in range(2_000)] - with patch( - "litellm.proxy.pass_through_endpoints.pass_through_endpoints._is_sendable_header_value" - ) as is_sendable: - headers: Final = _guardrail_response_headers({"metadata": {"applied_guardrails": names}}) - - assert headers == {} - is_sendable.assert_not_called() + assert _guardrail_response_headers({"metadata": {"applied_guardrails": names}}) == {} @pytest.mark.parametrize("control", ["\x01", "\x1f", "\x7f", "\x00", "\n"]) def test_guardrail_name_with_a_control_character_stays_out_of_the_header(self, control):