Skip to content

Conversation

andrewheard
Copy link
Contributor

@andrewheard andrewheard commented Aug 27, 2025

Added handling for GenerateContentResponse values that contain no parts. When streaming, these are skipped since the developer can't act upon them. In unary calls, throws only if all candidates are empty since, unlike streaming, no additional responses will be returned by the backend (and therefore an empty response would be an error).

This PR resolves decoding issues when using the gemini-2.5-flash-image-preview ("nano banana") model with the Gemini Developer API to generate images, as well as hardening the decoding against malformed responses that were being returned by Vertex AI (now fixed in the backend).

@andrewheard andrewheard added this to the 12.3.0 - M170 milestone Sep 3, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces robust handling for empty or unknown Part data in GenerateContentResponse. For streaming calls, responses with only empty candidates are now skipped, improving the developer experience. For unary calls, an error is thrown only if all candidates in a response are empty. This is a solid improvement that also resolves decoding issues with newer models. The changes are well-structured, and the addition of new tests and updates to existing ones ensure the new logic is covered. I have one minor suggestion to use a more specific log code.

@andrewheard andrewheard marked this pull request as ready for review September 3, 2025 22:42
@andrewheard andrewheard merged commit 9f4c34b into main Sep 3, 2025
47 checks passed
@andrewheard andrewheard deleted the ah/ai-unsupported-part-data branch September 3, 2025 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants