[firebase_vertexai]: Server Error not handle - JSON error unexpected character at (0) #13221
Closed
1 task done
Labels
Needs Attention
This issue needs maintainer attention.
platform: all
Issues / PRs which are for all platforms.
plugin: vertexai
label issues for vertexai plugin
resolution: solution-provided
A solution has been provided in the issue.
type: bug
Something isn't working
Is there an existing issue for this?
Which plugins are affected?
Other
Which platforms are affected?
Android, iOS, macOS, Web, Windows
Description
This is a problem in the "google-generative-ai" package, already reported in the issue: google-gemini/generative-ai-dart#206
And already created a pull request to handle the error: google-gemini/generative-ai-dart#207
I'm reporting the error here as I came across the problem while using the Vertex AI package, and to help other facing this issue while using it.
Description:
When calling generateContent and the server responses with an error like +500, instead of throwing and giving a clear error, the makeRequest method tries to decode de result and breaks with a "JSON error unexpected character at (0)".
This is very confusing and not clear about the real problem.
Reproducing the issue
In this case we are going to try and process and image, pdf or other file stored in "Cloud Storage/Firebase Storage" through a "gs://" url. But the server won't have access to the files and response with a 502 error.
Other types of generation will work perfectly, thus the confusion when the generating content responses with "Json parse" error.
The replication case is rare, but happened to me when enabling the Vertex AI API in Google Cloud, for some reason it did not setup the permission for the bucket in Firebase right.
*This considers that you are using Firebase with "VertexAI" and have already enable the API in the project and have it working.
Firebase Core version
3.1.1
Flutter Version
3.19.6
Relevant Log Output
No response
Flutter dependencies
No response
Additional context and comments
No response
The text was updated successfully, but these errors were encountered: