Skip to content

Gemini API returns 503 error with MissingFieldExceptionΒ #220

@surajsahani

Description

@surajsahani

Description of the bug:

When interacting with the Gemini API, the following error message is received in the log:

D  Error message received: Unexpected Response:
{
  "error": {
    "code": 503,
    "message": "The model is overloaded. Please try again later.",
    "status": "UNAVAILABLE"
  }
}
kotlinx.serialization.MissingFieldException: Field 'details' is required for type with serial name 'com.google.ai.client.generativeai.common.server.GRpcError', but it was missing at path: $.error

This indicates that the API is overloaded, but it also throws a MissingFieldException related to the 'details' field when parsing the response.

Actual vs expected behavior:

Actual: The response includes a 503 error code with the message "The model is overloaded." Additionally, a MissingFieldException is thrown due to the missing 'details' field.
Expected: The API should either provide a valid response with the necessary 'details' field or handle missing fields gracefully without throwing an exception.

Any other information you'd like to share?

This error occurs during normal API interaction when the model is under heavy load. It would be helpful to have the API gracefully handle missing fields in error responses to prevent application crashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions