Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_vertexai]: Server Error not handle - JSON error unexpected character at (0) #13221

Closed
1 task done
Flucadetena opened this issue Aug 26, 2024 · 4 comments
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

Comments

@Flucadetena
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

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.

  • Go to the connected Firebase project in Google Cloud, under the section "Cloud Storage".
  • Select the bucket "{ProjectId}.appspot.com
  • Go to "permissions" tab on the top
  • Under "View By Principals" delete the "service agent for Vertext AI" automatically generated when enabling the API Google Cloud. Normally with a "principal" like "service-34738934@gcp-sa-aiplatform.iam.gserviceaccount.com"
  • After this, the API won't have access to the bucket, so when you try to generate content with a file stored in it, the server will response with a 502 error and prompt the error described above.

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

@Flucadetena Flucadetena added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Aug 26, 2024
@SelaseKay
Copy link
Contributor

Hi @Flucadetena, Kindly provide a sample minimal code reproducing this issue.

@SelaseKay SelaseKay added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Aug 27, 2024
@Flucadetena
Copy link
Author

Hi @SelaseKay I've already provided instructions to run this issue. By simply running the sample app and adding a file via "gs://" url without the permissions it will break.

As you have to configure this on your end with your firebase project, there is not much code I can provide.

If you are more specific i'll be happy to help.

@google-oss-bot google-oss-bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Aug 27, 2024
@SelaseKay SelaseKay added platform: all Issues / PRs which are for all platforms. plugin: vertexai label issues for vertexai plugin labels Aug 27, 2024
@Lyokone
Copy link
Contributor

Lyokone commented Sep 2, 2024

Hello @Flucadetena, I've pinged internally so someone would review your PR . Since there is nothing to fix directly on the FlutterFire repository, I'll go ahead and close this issue.

@Lyokone Lyokone closed this as completed Sep 2, 2024
@Lyokone Lyokone added resolution: invalid This doesn't seem right and might not belong here. resolution: solution-provided A solution has been provided in the issue. and removed resolution: invalid This doesn't seem right and might not belong here. labels Sep 2, 2024
@Flucadetena
Copy link
Author

Awesome @Lyokone completely agree.

If I can help any further let me know.

Hope you have a nice day ;)

@firebase firebase locked and limited conversation to collaborators Oct 3, 2024
@github-staff github-staff deleted a comment from Lxx-c Oct 23, 2024
@github-staff github-staff deleted a comment from Lxx-c Oct 23, 2024
@github-staff github-staff deleted a comment from Lxx-c Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

No branches or pull requests

8 participants
@Lyokone @google-oss-bot @Flucadetena @SelaseKay and others