mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
test(proxy): pin that reconciliation survives search-tool parse failures
parse_search_tools operates on the dict get_config() already returned and swallows per-tool errors itself, so a raise from it leaves config_data a fully valid config with litellm_settings.callbacks untouched. Reconciling against it is correct. Deferring config_loaded until after that call looks safer but is not: a persistently malformed search_tools section would then skip reconciliation on every poll, so a revoked interception callback would keep serving paid searches indefinitely. This pins the ordering so it cannot be quietly reversed.
This commit is contained in:
parent
0e918025c6
commit
f7fe8ef441
1 changed files with 27 additions and 0 deletions
|
|
@ -2073,6 +2073,33 @@ async def test_ProxyConfig__update_llm_router_keeps_logger_when_config_load_fail
|
|||
assert snapshot == {"installed_before": 1, "remaining": 1}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ProxyConfig__update_llm_router_reconciles_when_search_tool_parsing_fails(monkeypatch):
|
||||
from litellm.integrations.websearch_interception.handler import (
|
||||
WebSearchInterceptionLogger,
|
||||
)
|
||||
|
||||
_reset_callback_lists(monkeypatch)
|
||||
pc = ProxyConfig()
|
||||
pc._add_callbacks_from_db_config(_websearch_db_config("tavily-search", ["bedrock"]))
|
||||
installed_before = [cb for cb in litellm.callbacks if isinstance(cb, WebSearchInterceptionLogger)]
|
||||
|
||||
class _MalformedSearchToolsProxyConfig:
|
||||
async def get_config(self) -> dict:
|
||||
return {"litellm_settings": {}, "search_tools": "not-a-list"}
|
||||
|
||||
monkeypatch.setattr(litellm.proxy.proxy_server, "proxy_config", _MalformedSearchToolsProxyConfig())
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
pc.parse_search_tools({"search_tools": "not-a-list"})
|
||||
|
||||
await pc._update_llm_router(new_models=[], proxy_logging_obj=MagicMock())
|
||||
|
||||
remaining = [cb for cb in litellm.callbacks if isinstance(cb, WebSearchInterceptionLogger)]
|
||||
snapshot = {"installed_before": len(installed_before), "remaining": len(remaining)}
|
||||
assert snapshot == {"installed_before": 1, "remaining": 0}
|
||||
|
||||
|
||||
def test_ProxyConfig__add_callbacks_from_db_config_bad_config_raises():
|
||||
pc = ProxyConfig()
|
||||
with pytest.raises(AttributeError):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue