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

[Vertex AI] Log server error responses without -FIRDebugEnabled #13009

Merged
merged 1 commit into from
May 21, 2024

Conversation

andrewheard
Copy link
Contributor

Updated logging to print response payloads even when -FIRDebugEnabled is not enabled.

Example Error Response Log If the Vertex AI API (aiplatform.googleapis.com) is not enabled:
[FirebaseVertexAI] Response payload: {
  "error": {
    "code": 403,
    "message": "Vertex AI API has not been used in project my-project-id before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/aiplatform.googleapis.com/overview?project=my-project-id then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developers console API activation",
            "url": "https://console.developers.google.com/apis/api/aiplatform.googleapis.com/overview?project=my-project-id"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "SERVICE_DISABLED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "aiplatform.googleapis.com",
          "consumer": "projects/my-project-id"
        }
      }
    ]
  }
}

Updated logging to only print the NSHTTPURLResponse if -FIRDebugEnabled is enabled.

Example NSHTTPURLResponse Log
[FirebaseVertexAI] The server responded with an error: <NSHTTPURLResponse: 0x60000030a580> { URL: https://firebaseml.googleapis.com/v2beta/projects/my-project-id/locations/us-central1/publishers/google/models/gemini-1.5-flash-preview-0514:streamGenerateContent?alt=sse } { Status Code: 403, Headers {
    "Alt-Svc" =     (
        "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"
    );
    "Content-Length" =     (
        1048
    );
    "Content-Type" =     (
        "text/event-stream"
    );
    Date =     (
        "Tue, 21 May 2024 22:28:32 GMT"
    );
    Server =     (
        ESF
    );
    Vary =     (
        Origin,
        "X-Origin",
        Referer
    );
    "x-content-type-options" =     (
        nosniff
    );
    "x-frame-options" =     (
        SAMEORIGIN
    );
    "x-xss-protection" =     (
        0
    );
} }

These were swapped because the NSHTTPURLResponse is rarely useful for understanding an error on its own, whereas the response payload contains details to fix the problem.

#no-changelog

@andrewheard andrewheard merged commit bf7272d into main May 21, 2024
42 checks passed
@andrewheard andrewheard deleted the ah/vertex-log-error-payloads branch May 21, 2024 22:45
@firebase firebase locked and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants