Repository navigation
refactor(gateway): remove redundant connection_mode special-case for external providers - #680
Conversation
…ction_mode detection The OpenAI routing mode was hardcoded to ConnectionMode::Http instead of going through determine_connection_mode(). This was a safety measure from the original OpenAI backend PR, but after the gRPC detection was simplified to scheme-only checking (grpc:// or grpcs://), the special case is unnecessary — external provider URLs (https://) always resolve to Http. Removing it prevents each new external provider from needing its own match arm. Signed-off-by: Chang Su <chang.s.su@oracle.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the connection mode detection logic within the gateway. It eliminates a specific handling for OpenAI, allowing all external providers to uniformly determine their connection mode through a single, consistent function call. This change simplifies the codebase, improves maintainability, and ensures future external providers are handled correctly without requiring additional special-casing. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe connection mode determination logic in the gateway's main entry point is refactored to consistently rely on URL scheme inspection rather than conditionally forcing Http mode when using OpenAI routing, simplifying the configuration flow. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors the connection mode detection by removing a special case for OpenAI providers. The change simplifies the logic by unconditionally using determine_connection_mode(), which correctly infers the connection type from the URL scheme. This is a good simplification that improves code clarity and makes it more robust for adding future external providers.
Description
Problem
The
connection_modedetection inmain.rshad a special-case match arm that hardcodedRoutingMode::OpenAItoConnectionMode::Http, bypassingdetermine_connection_mode(). This was a safety measure from the original OpenAI backend PR, but after Simo's cleanup in #9999 (simplified gRPC detection to scheme-only checking), it became redundant. Each new external provider (Anthropic, now Gemini in #679) was forced to either add its own match arm or fall through to URL detection accidentally.Solution
Remove the
RoutingModematch and calldetermine_connection_mode()unconditionally. External provider URLs (https://...) never start withgrpc://, so they always resolve toConnectionMode::Httpthrough the normal path. The factory already has error guards for invalid gRPC + external provider combinations as a safety net.Changes
RoutingMode::OpenAIspecial-case match inCliArgs::to_server_config(), replacing it with a direct call toSelf::determine_connection_mode(&all_urls)Test Plan
cargo check -p smgpasseshttps://, whichdetermine_connection_mode()already resolves toConnectionMode::HttpChecklist
cargo +nightly fmtpassescargo clippy --all-targets --all-features -- -D warningspassesSummary by CodeRabbit
Bug Fixes