mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-27 01:22:18 +00:00
fix: drop a blank anthropic-beta header before it reaches the provider
This commit is contained in:
parent
c13dcb0abf
commit
0f0c0fe499
2 changed files with 19 additions and 1 deletions
|
|
@ -334,7 +334,7 @@ def update_headers_with_filtered_beta(
|
|||
Updated headers dict
|
||||
"""
|
||||
existing_beta: Final = headers.get("anthropic-beta")
|
||||
if not existing_beta:
|
||||
if existing_beta is None:
|
||||
return headers
|
||||
|
||||
# Parse existing beta headers
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import pytest
|
|||
import litellm
|
||||
from litellm.anthropic_beta_headers_manager import (
|
||||
filter_and_transform_beta_headers,
|
||||
update_headers_with_filtered_beta,
|
||||
update_request_with_filtered_beta,
|
||||
)
|
||||
|
||||
|
|
@ -511,3 +512,20 @@ class TestAnthropicBetaHeadersFiltering:
|
|||
assert (
|
||||
"unknown-header-123" not in filtered
|
||||
), f"Unknown header should not be in result for {provider}"
|
||||
|
||||
@pytest.mark.parametrize("provider", ["anthropic", "bedrock", "bedrock_mantle", "vertex_ai"])
|
||||
def test_blank_anthropic_beta_header_is_removed(self, provider):
|
||||
headers = {"anthropic-beta": "", "anthropic-version": "2023-06-01"}
|
||||
|
||||
assert update_headers_with_filtered_beta(headers, provider) == {"anthropic-version": "2023-06-01"}
|
||||
|
||||
@pytest.mark.parametrize("provider", ["anthropic", "bedrock", "bedrock_mantle", "vertex_ai"])
|
||||
def test_whitespace_only_anthropic_beta_header_is_removed(self, provider):
|
||||
headers = {"anthropic-beta": " , ", "anthropic-version": "2023-06-01"}
|
||||
|
||||
assert update_headers_with_filtered_beta(headers, provider) == {"anthropic-version": "2023-06-01"}
|
||||
|
||||
def test_absent_anthropic_beta_header_is_left_alone(self):
|
||||
headers = {"anthropic-version": "2023-06-01"}
|
||||
|
||||
assert update_headers_with_filtered_beta(headers, "bedrock_mantle") == {"anthropic-version": "2023-06-01"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue