-
Notifications
You must be signed in to change notification settings - Fork 5k
fix(plugins/ai-proxy): the request will panic if the model name with /
#14805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
For Gemini/VertexAI, it concats the model name in the url, so it will return NOT FOUND error if the model name wrongly brings the provider prefix like `google/gemini-2.5-flash`. And it will raise an error while decoding the empty string with `cjson` instead of `cjson.safe`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a panic issue in the ai-proxy plugin when model names contain forward slashes (e.g., "google/gemini-2.5-flash"). When such model names are used with Gemini/VertexAI providers, they are concatenated into the URL path, resulting in invalid API requests that return empty or malformed responses. The fix migrates from the regular cjson library to cjson.safe, which returns errors instead of throwing exceptions, preventing service panics when decoding these empty responses.
Key Changes:
- Switched from
cjsontocjson.safeto handle JSON decode failures gracefully - Added explicit error handling with logging for decode failures
- Used nil-safe access pattern for the decoded response table
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@oowl @StarlightIbuki Would you mind taking a look this? |
fc07f17 to
39b9502
Compare
Summary
For Gemini/VertexAI, it concats the model name in the url, so it will return NOT FOUND error if the model name wrongly brings the provider prefix like
google/gemini-2.5-flash. And it will raise an error while decoding the empty string withcjsoninstead ofcjson.safe.Checklist
changelog/unreleased/kongorskip-changeloglabel added on PR if changelog is unnecessary. README.md