fix(firebase_ai): Rename groundingSupport to groundingSupports#17961
Conversation
We currently parse for a `groundingSupport` field, when it should be `groundingSupports`. This fixes an issue where groundingSupports are not parse in responses, and cannot be retrieved by users.
| /// Each object details how specific segments of the | ||
| /// model's response are supported by the `groundingChunks`. | ||
| final List<GroundingSupport> groundingSupport; | ||
| final List<GroundingSupport> groundingSupports; |
There was a problem hiding this comment.
| final List<GroundingSupport> groundingSupports; | |
| final List<GroundingSupport> groundingSupports; | |
| /// A list of [GroundingSupport]s. | |
| @Deprecated('Use groundingSupports instead') | |
| List<GroundingSupport> get groundingSupport => groundingSupports; |
cynthiajoan
left a comment
There was a problem hiding this comment.
keep the current groundingSupport and mark it as deprecated
|
/gemini review |
There was a problem hiding this comment.
Code Review
The pull request successfully renames the groundingSupport field to groundingSupports throughout the codebase, including the API definition, parsing logic, and all associated tests. This change correctly addresses the parsing issue and aligns the field name with the expected plural form. Additionally, the update in _parseGroundingSupport to use ?.cast<int>() enhances type safety and robustness when handling list casting.
| segment: segment, | ||
| groundingChunkIndices: | ||
| (jsonObject['groundingChunkIndices'] as List<int>?) ?? []); | ||
| (jsonObject['groundingChunkIndices'] as List?)?.cast<int>() ?? []); |
There was a problem hiding this comment.
This change from as List<int>? to as List?)?.cast<int>() is a good improvement for type safety. It correctly handles cases where jsonObject['groundingChunkIndices'] might be a List<dynamic> or List<Object?> rather than directly List<int>, preventing potential runtime errors.
| (jsonObject['groundingChunkIndices'] as List?)?.cast<int>() ?? []); | |
| (jsonObject['groundingChunkIndices'] as List?)?.cast<int>() ?? [] |
We currently parse for a
groundingSupportfield, when it should begroundingSupports. This fixes an issue wheregroundingSupportsare not parsed in responses or present in the API, and cannot be retrieved by users.Fixes b/477107542