fix(proxy): support slashes in google generateContent model names (#1… - #19753
Conversation
…9737) * fix(proxy): support slashes in google route params * fix(proxy): extract google model ids with slashes * test(proxy): cover google model ids with slashes
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
* fix(mcp): Add standard MCP URL pattern support for OAuth discovery (#17272) OAuth discovery endpoints now support both URL patterns: - Standard MCP pattern: /mcp/{server_name} (new) - Legacy LiteLLM pattern: /{server_name}/mcp (backward compatible) The standard pattern is required by MCP-compliant clients like mcp-inspector and VSCode Copilot, which expect resource URLs following the /mcp/{server_name} convention per RFC 9728. Changes: - Add _build_oauth_protected_resource_response() helper - Add oauth_protected_resource_mcp_standard() endpoint - Add oauth_authorization_server_mcp_standard() endpoint - Keep legacy endpoints for backward compatibility - Add tests for both URL patterns Fixes #17272 * fix(mcp): Add standard MCP URL pattern support for OAuth discovery (#17272) OAuth discovery endpoints now support both URL patterns: - Standard MCP pattern: /mcp/{server_name} (new) - Legacy LiteLLM pattern: /{server_name}/mcp (backward compatible) The standard pattern is required by MCP-compliant clients like mcp-inspector and VSCode Copilot, which expect resource URLs following the /mcp/{server_name} convention per RFC 9728. Changes: - Add _build_oauth_protected_resource_response() helper - Add oauth_protected_resource_mcp_standard() endpoint - Add oauth_authorization_server_mcp_standard() endpoint - Keep legacy endpoints for backward compatibility - Add tests for both URL patterns Fixes #17272 * Test was relocated * refactor(mcp): Extract helper methods from run_with_session to fix PLR0915 Split the large run_with_session method (55 statements) into smaller helper methods to satisfy ruff's PLR0915 rule (max 50 statements): - _create_transport_context(): Creates transport based on type - _execute_session_operation(): Handles session lifecycle Also changed cleanup exception handling from Exception to BaseException to properly catch asyncio.CancelledError (which is a BaseException subclass in Python 3.8+). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test(mcp): Fix flaky test by mocking health_check_server The test_mcp_server_manager_config_integration_with_database test was making real network calls to fake URLs which caused timeouts and CancelledError exceptions. Fixed by mocking health_check_server to return a proper LiteLLM_MCPServerTable object instead of making network calls. * test(mcp): Fix skip condition to properly detect claude model names The skip condition for missing API keys was checking for "anthropic" in the model name, but the test uses "claude-haiku-4-5" which doesn't match. Updated to check for both "anthropic" and "claude" model patterns. Also added skip condition for OpenAI models when OPENAI_API_KEY is not set. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test(mcp): Fix skip condition to properly detect claude model names The skip condition for missing API keys was checking for "anthropic" in the model name, but the test uses "claude-haiku-4-5" which doesn't match. Updated to check for both "anthropic" and "claude" model patterns. Also added skip condition for OpenAI models when OPENAI_API_KEY is not set. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* feat: add clientip and user agent in metrics * fix: lint errors * Add model id and other req labels --------- Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
* add timeout to onyx guardrail * add tests
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| url=self.server_url, | ||
| http_client=http_client, | ||
| ) | ||
| return transport_ctx, http_client |
There was a problem hiding this comment.
MCP HTTP transport crashes when import fails
High Severity
The code sets streamable_http_client = None when the import fails, but then calls streamable_http_client(...) directly without checking if it's None. When HTTP transport is used (the default) and the mcp.client.streamable_http module is unavailable (e.g., older MCP package version), this will raise a TypeError: 'NoneType' object is not callable.
Additional Locations (1)
| self, api_base: Optional[str] = None, api_key: Optional[str] = None, **kwargs | ||
| self, api_base: Optional[str] = None, api_key: Optional[str] = None, timeout: Optional[float] = 10.0, **kwargs | ||
| ): | ||
| timeout = timeout or int(os.getenv("ONYX_TIMEOUT", 10.0)) |
There was a problem hiding this comment.
Onyx timeout uses int() causing ValueError on floats
Medium Severity
The timeout fallback uses int(os.getenv("ONYX_TIMEOUT", 10.0)), which will raise a ValueError if a user sets ONYX_TIMEOUT to a decimal value like "2.5". Since timeout is typed as Optional[float] and httpx.Timeout accepts floats, float() should be used instead of int().
| try: | ||
| from mcp.server.streamable_http_manager import StreamableHTTPSessionManager | ||
| except ImportError: | ||
| StreamableHTTPSessionManager = None # type: ignore |
There was a problem hiding this comment.
MCP server crashes when session manager import fails
High Severity
The code sets StreamableHTTPSessionManager = None when the import fails, but it's then used at module load time (lines 128 and 136) without checking for None. When the MCP package is installed but missing the streamable_http_manager module, the MCP server will fail to initialize with a TypeError: 'NoneType' object is not callable.
Additional Locations (1)
…26_2026 fix(proxy): support slashes in google generateContent model names (#1…
…9737)
fix(proxy): support slashes in google route params
fix(proxy): extract google model ids with slashes
test(proxy): cover google model ids with slashes
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test
Changes
Note
generateContent/countTokenspaths; improved extraction in auth utils; updated route matching; new unit tests.client_ip,user_agent, and broadermodel_idpropagation; new deploymenttpm/rpmlimit gauges; adjust remaining API key metrics labels; improved invalid-key filtering; comprehensive tests.X-Forwarded-*headers; added tests incl. PKCE.timeout(config/envONYX_TIMEOUT), use httpx with timeouts; docs updated; tests for timeouts/error handling./get_imageasync, add on-disk caching and timeouted async fetch with graceful fallback; tests added.tpm/rpmin params; includeuser_agentin standard logging; minor formatting/cleanup.Written by Cursor Bugbot for commit aa8134f. This will update automatically on new commits. Configure here.