Bug: Intermittent NullPointerException in Firebase Vertex AI Imagen Generation #17199
Labels
Needs Attention
This issue needs maintainer attention.
plugin: vertexai
label issues for vertexai plugin
type: bug
Something isn't working
Description
When calling
generateImages()
on the Firebase Vertex AI Imagen model, we're seeing intermittent null pointer exceptions. The error occurs approximately 50% of the time when the function is called.Error Details
Steps to Reproduce
await model.generateImages(prompt)
with a valid text promptExpected Behavior
The
generateImages()
method should consistently return valid image data without throwing exceptions.Actual Behavior
In approximately 50% of the calls, the method throws a
NoSuchMethodError
because it's trying to callisEmpty
on a null value during response parsing inImagenGenerationResponse.fromJson
.Environment
Possible Causes
Looking at the stack trace, the issue is in
ImagenGenerationResponse.fromJson
at line 105 inimagen_content.dart
. The code is trying to access a property and callisEmpty
on it, but is receiving null instead of the expected object or array.Suggested Fix
The library should add null safety checks in the
fromJson
method to handle cases where the expected field is missing or null in the API response.The text was updated successfully, but these errors were encountered: