Fix: Update deprecated Gemini model and error logging for silent bot response failures. - #411
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe default Gemini model changed to ChangesGemini response handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This localized change updates the default Gemini model and improves visibility into failed responses; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@syedbarkath980 Good Catch but I have never seen such msg till now. |
|
No, that message was shown AFTER i added a log line: log.Printf("❌ Gemini error in GenerateBotResponse: %v", err) in GenerateBotResponse function which was not present before i made the change. It is added to catch and show the error thrown by gemini in case of any issue caused by the gemini api. |
Problem
Vs-bot debate responses and judging were failing silently, returning generic personality-flavored fallback messages instead of real AI-generated responses — even with a valid and correctly configured Gemini API key.
There were two separate issues contributing to the problem.
Root Cause
1. Gemini errors were silently swallowed
GenerateBotResponsediscarded the actual Gemini error and returned a hardcoded, in-character fallback message instead.For example, when the Rookie Rick bot's Gemini request failed, the user would receive:
This fallback is defined per bot in
personalityErrorResponse:The issue was inconsistent with
JudgeDebatein the same file, which already logs Gemini errors:Whereas
GenerateBotResponsepreviously did this:As a result, the underlying Gemini failure was completely invisible in the server logs.
Every request still returned a
200 OKwith a plausible-looking, in-character response, making the failure appear to be normal application behavior.The actual error only became visible after temporary debug logging was added to
GenerateBotResponse.2. Deprecated Gemini model
Once the underlying error was exposed, the actual failure was identified as a 404 from Google:
The project was using the hardcoded model:
This model is no longer available to new Gemini API keys, meaning new contributors setting up the project with a freshly created API key could encounter the same failure.
Fix
Two changes were made:
Error logging
Added error logging in case of failure for Gemini API errors in
GenerateBotResponseThis brings
GenerateBotResponsein line with the existing error-handling behavior inJudgeDebate.Gemini model update
Updated the default Gemini model:
NOTE: Needs Clarification for the Existing users with 2.5 version:
Google's error message specifically states that
gemini-2.5-flashis "no longer available to new users."This may imply that existing API keys or deployments could still be able to use the older model. I wasn't able to verify this independently because testing was performed with a newly created Gemini API key.
Therefore, if an existing deployment is currently relying on
gemini-2.5-flash, this model change could potentially affect it as well.This is being called out explicitly rather than assuming that existing users are unaffected.
Before
Vs-bot returned generic personality-specific fallback messages instead of actual debate responses:
The Gemini failure was also not visible in the server logs.
improper.ai.response.before-fix.mp4
After
Vs-bot successfully returns contextual, AI-generated debate responses using the updated Gemini model.
improper.ai.response.after-fix.mp4
Summary by CodeRabbit