fix: strip uniqueItems from Gemini function_declarations (#2123)#2142
Conversation
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 addresses a compatibility issue with the Gemini API by ensuring that the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
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
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where the Gemini API rejects schemas containing the uniqueItems keyword. The fix correctly adds uniqueItems to the list of unsupported constraints, ensuring it's stripped from the schema before being sent to the API. The change is straightforward and follows the existing pattern for handling unsupported schema properties. I've suggested adding a test case to verify this new behavior and prevent future regressions.
| var unsupportedConstraints = []string{ | ||
| "minLength", "maxLength", "exclusiveMinimum", "exclusiveMaximum", | ||
| "pattern", "minItems", "maxItems", "format", | ||
| "pattern", "minItems", "maxItems", "uniqueItems", "format", |
There was a problem hiding this comment.
This change correctly adds uniqueItems to the list of unsupported constraints. To ensure this fix is robust and prevent future regressions, it would be beneficial to add a new test case to internal/util/gemini_schema_test.go. This test should verify that the uniqueItems keyword is removed from the schema and a corresponding hint is added to the description, similar to how other constraints like minItems are tested.
Covers the fix from the previous commit — verifies uniqueItems is removed from the schema and moved to the description hint.
|
Added a test in the follow-up commit - verifies uniqueItems is stripped and the description hint is added. |
luispater
left a comment
There was a problem hiding this comment.
Summary
This change fixes the reported Gemini schema rejection by stripping uniqueItems alongside the other unsupported constraints and preserving it as a description hint. The implementation is consistent with the existing sanitizer flow, and the added regression test covers the shared constraint-to-description path.
Key findings
- No blocking issues found.
- Non-blocking: consider adding a
CleanJSONSchemaForGeminiregression test too, since that is the directly reported failing entry point.
Test plan
- Reviewed the diff for
internal/util/gemini_schema.goandinternal/util/gemini_schema_test.go - Ran
go test ./internal/utilon the PR head - Ignored
translator-path-guardper instructions
This is an automated Codex review result and still requires manual verification by a human reviewer.
…eItems-gemini-2123 fix: strip uniqueItems from Gemini function_declarations (router-for-me#2123)
Fixes #2123
Gemini API rejects
uniqueItemsin tool schemas:400 Unknown name "uniqueItems" at 'request.tools0.function_declarations43.parameters.properties2.value'
Added
uniqueItemstounsupportedConstraintsingemini_schema.goalongsideminItems/maxItems- same approach as #1424 and #1531.All existing schema sanitization tests pass.