mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
test(mcp): cover user_fields header template fallback for codecov
Adds a regression test for the AttributeError fallback in resolve_user_field_headers when a corrupt JSONB row carries a non-string header_value_template. Bumps patch coverage past the codecov auto target.
This commit is contained in:
parent
a6ae106cf1
commit
56790e43eb
1 changed files with 19 additions and 0 deletions
|
|
@ -330,6 +330,25 @@ def test_resolve_user_field_headers_does_not_evaluate_attribute_access():
|
|||
assert headers == {"Authorization": "Bearer {value.__class__}"}
|
||||
|
||||
|
||||
def test_resolve_user_field_headers_falls_back_on_non_string_template():
|
||||
"""A corrupt JSONB row may carry a non-string ``header_value_template``
|
||||
(e.g. an int from an external write that bypassed the API). The resolver
|
||||
must catch the resulting ``AttributeError`` from ``int.replace`` and fall
|
||||
back to the raw user value rather than crashing the request path."""
|
||||
srv = _gmail_server(
|
||||
user_fields=[
|
||||
{
|
||||
"field_key": "TOKEN",
|
||||
"header_name": "Authorization",
|
||||
"header_value_template": 42,
|
||||
"required": True,
|
||||
}
|
||||
]
|
||||
)
|
||||
headers = resolve_user_field_headers(srv, {"TOKEN": "raw-tok"})
|
||||
assert headers == {"Authorization": "raw-tok"}
|
||||
|
||||
|
||||
def test_resolve_user_field_headers_skips_entries_missing_header_name():
|
||||
"""Stdio-only fields (no header_name) must not produce empty-name headers."""
|
||||
srv = MCPServer(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue