Skip to content

.Net: Fix Google Gemini API compatibility by filtering unsupported format fields#12972

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-adf5110f-3fce-49c2-ae1d-5842954c3f62
Closed

.Net: Fix Google Gemini API compatibility by filtering unsupported format fields#12972
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-adf5110f-3fce-49c2-ae1d-5842954c3f62

Conversation

Copilot AI commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

Problem

Google's Gemini API has updated their validation to only accept "enum" and "date-time" format fields for string types in OpenAPI schemas. This causes function calls with GUID/UUID parameters to fail with validation errors like:

"GenerateContentRequest.tools[0].function_declarations[1].parameters.properties[myReference].properties[MyProperty].format: only 'enum' and 'date-time' are supported for STRING type"

When .NET serializes schemas for types like Guid, it includes format fields (e.g., "format": "uuid") that are now rejected by Google's API.

Solution

Modified the TransformOpenApi3Object method in GeminiRequest.cs to strip unsupported format fields from string type properties during schema transformation. The fix:

  1. Preserves supported formats: "enum" and "date-time" formats are kept as required by Google's API
  2. Removes unsupported formats: All other format fields (like "uuid", "email", "phone", etc.) are stripped from string properties
  3. Maintains existing behavior: All other schema transformations continue to work as before

Changes

  • Added format field filtering logic in TransformOpenApi3Object method
  • Added comprehensive test ResponseSchemaStripsUnsupportedFormatFields to verify the behavior
  • Fixed variable name conflict in the same method scope

Testing

  • ✅ New test verifies that unsupported formats are stripped while supported formats are preserved
  • ✅ All 317 existing Google connector unit tests continue to pass
  • ✅ All 34 existing GeminiRequestTests continue to pass

This minimal change ensures compatibility with Google's updated API validation while preserving all existing functionality.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…at fields

Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Copilot AI changed the title [WIP] Try implementing the suggested fix by @DevEnable for this issue #12957, TransformOpenApi3Object only stripping the "format" property if it doesn't equal "enum" or "date-time". Fix Google Gemini API compatibility by filtering unsupported format fields Aug 19, 2025
Copilot AI requested a review from rogerbarreto August 19, 2025 19:50
@moonbox3 moonbox3 added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Aug 19, 2025
@github-actions github-actions Bot changed the title Fix Google Gemini API compatibility by filtering unsupported format fields .Net: Fix Google Gemini API compatibility by filtering unsupported format fields Aug 19, 2025
@rogerbarreto rogerbarreto marked this pull request as ready for review August 29, 2025 16:51
@rogerbarreto rogerbarreto requested a review from a team as a code owner August 29, 2025 16:51
@rogerbarreto rogerbarreto marked this pull request as draft September 10, 2025 12:35
@rogerbarreto

Copy link
Copy Markdown
Member

Closing for now, will re-open later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.Net: Bug: Google Connector Fails with GUIDs in Function Calls

3 participants