From ba97bc28afdb50607e0674f6902448311f5a1b97 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 7 Mar 2026 11:03:19 -0800 Subject: [PATCH] fix: add auto-close to error HTML popup, strengthen spec_path registry test - Error HTML page now auto-closes the popup after 4s (same as success page), stopping the 2s polling loop and clearing the loading spinner so users aren't left in a confused state after a provider error. - Replace trivial `assert manager is not None` with a meaningful assertion: patch _create_mcp_client and verify it is NOT called for spec_path servers, directly testing the short-circuit in _get_tools_from_server. --- .../mcp_server/openapi_oauth2_endpoints.py | 4 ++++ .../test_openapi_oauth2_endpoints.py | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/_experimental/mcp_server/openapi_oauth2_endpoints.py b/litellm/proxy/_experimental/mcp_server/openapi_oauth2_endpoints.py index d6f0d5b1a4e..9fd1be888b7 100644 --- a/litellm/proxy/_experimental/mcp_server/openapi_oauth2_endpoints.py +++ b/litellm/proxy/_experimental/mcp_server/openapi_oauth2_endpoints.py @@ -125,6 +125,10 @@ def _build_error_html(title: str, message: str) -> str: h2 {{ color: #dc2626; font-size: 20px; margin-bottom: 12px; }} p {{ color: #475569; font-size: 14px; line-height: 1.6; }} +
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_openapi_oauth2_endpoints.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_openapi_oauth2_endpoints.py index 62408d52bc8..793a190d980 100644 --- a/tests/test_litellm/proxy/_experimental/mcp_server/test_openapi_oauth2_endpoints.py +++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_openapi_oauth2_endpoints.py @@ -585,8 +585,22 @@ def test_spec_path_server_uses_tool_registry(): assert server.spec_path == "https://example.com/openapi.json" assert server.is_byok is True - # The spec_path short-circuit in _get_tools_from_server is conditional on this field - assert manager is not None + + # Verify the manager's short-circuit path: _get_tools_from_server checks + # spec_path before attempting MCP client creation. We confirm this by + # patching _create_mcp_client and asserting it is NOT called when spec_path is set. + from unittest.mock import AsyncMock, patch + + with patch.object(manager, "_create_mcp_client", new_callable=AsyncMock) as mock_create: + # _get_tools_from_server is async but returns early for spec_path servers + import asyncio + + async def _run(): + return await manager._get_tools_from_server(server) + + asyncio.get_event_loop().run_until_complete(_run()) + + mock_create.assert_not_called() # ---------------------------------------------------------------------------