mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(proxy): treat a null public hub list as unset when publishing
This commit is contained in:
parent
82b4622947
commit
0577f5abe3
2 changed files with 25 additions and 2 deletions
|
|
@ -121,9 +121,10 @@ async def _upsert_param(table: _ConfigTable, param_name: str, value_json: str) -
|
|||
|
||||
|
||||
def public_hub_list(settings: Mapping[str, object], key: str, fallback: Sequence[str]) -> tuple[str, ...]:
|
||||
if key not in settings:
|
||||
stored: Final = settings.get(key)
|
||||
if stored is None:
|
||||
return tuple(fallback)
|
||||
return _STRING_LIST_ADAPTER.validate_python(settings[key])
|
||||
return _STRING_LIST_ADAPTER.validate_python(stored)
|
||||
|
||||
|
||||
class ConfigParam:
|
||||
|
|
|
|||
|
|
@ -1184,6 +1184,28 @@ def test_make_agent_public_appends_to_the_yaml_seeded_list(monkeypatch: pytest.M
|
|||
assert response.json()["public_agent_groups"] == ["yaml-seeded-agent", "agent-1"]
|
||||
|
||||
|
||||
def test_make_agent_public_treats_a_null_stored_key_as_unset(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""A stored ``public_agent_groups: null`` publishes like a missing key instead of failing the request."""
|
||||
import litellm
|
||||
from litellm.proxy.agent_endpoints import agent_registry as agent_registry_module
|
||||
from litellm.proxy.agent_endpoints.agent_registry import AgentRegistry
|
||||
|
||||
registry: Final = AgentRegistry()
|
||||
registry.register_agent(_sample_agent_response(agent_id="agent-1", agent_name="Agent One"))
|
||||
|
||||
proxy_config: Final = _DbBackedProxyConfig(stored={"public_agent_groups": None})
|
||||
monkeypatch.setattr(agent_registry_module, "global_agent_registry", registry)
|
||||
monkeypatch.setattr(litellm, "public_agent_groups", None)
|
||||
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", MagicMock())
|
||||
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", proxy_config)
|
||||
|
||||
response: Final = client.post("/v1/agents/agent-1/make_public", headers={"Authorization": "Bearer test-key"})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["public_agent_groups"] == ["agent-1"]
|
||||
assert proxy_config.stored_litellm_settings["public_agent_groups"] == ["agent-1"]
|
||||
|
||||
|
||||
def test_make_agents_public_keeps_the_published_mcp_servers(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""The bulk publish replaces its own key only."""
|
||||
import litellm
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue