Determine this is the right repository
Summary of the issue
Context
When using the Gemini model via Vertex AI, I encountered an inconsistent response format issue during error scenarios. The response.json() method returns a list when the API encounters an error, which contradicts the expected dictionary format—this format is consistently used for successful responses. This inconsistency breaks the unified response parsing logic in my application.
Expected Behavior:
Error responses should maintain the same dictionary format as successful responses.
Actual Behavior:
Error responses return a list via response.json().
Failed to transform agent message: req_id: Y7WO3wN4 PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [model_providers:large_language_model:gemini-2.0-flash-001] Error: req_id: 42eW2zZ9 PluginInvokeError: {"args":{},"error_type":"AttributeError","message":"'list' object has no attribute 'get' (model: gemini-2.0-flash-001, provider: vertex_ai)"}"}
API client name and version
google-api-core 2.26.0
Reproduction steps: code
for chunk in response:
pass
(google-api_core-exceptions)
def from_http_response(response):
try:
payload = response.json()
except ValueError:
payload = {"error": {"message": response.text or "unknown error"}}
return format_http_response_error(
response, response.request.method, response.request.url, payload
)
def format_http_response_error(
response, method: str, url: str, payload: Optional[Dict] = None
):
"""Create a :class:GoogleAPICallError from a google auth rest response.
Args:
response Union[google.auth.transport.Response, google.auth.aio.transport.Response]: The HTTP response.
method Optional(str): The HTTP request method.
url Optional(str): The HTTP request url.
payload Optional(dict): The HTTP response payload. If not passed in, it is read from response for a response type of google.auth.transport.Response.
Returns:
GoogleAPICallError: An instance of the appropriate subclass of
:class:`GoogleAPICallError`, with the message and errors populated
from the response.
"""
payload = {} if not payload else payload
error_message = **payload.get**("error", {}).get("message", "unknown error")
Reproduction steps: supporting files
file: mydata.csv
Reproduction steps: actual results
file: output.txtmydata.csv
Reproduction steps: expected results
file: output.txtmydata.csv
OS & version + platform
No response
Python environment
No response
Python dependencies
No response
Additional context
No response
Determine this is the right repository
Summary of the issue
Context
When using the Gemini model via Vertex AI, I encountered an inconsistent response format issue during error scenarios. The response.json() method returns a list when the API encounters an error, which contradicts the expected dictionary format—this format is consistently used for successful responses. This inconsistency breaks the unified response parsing logic in my application.
Expected Behavior:
Error responses should maintain the same dictionary format as successful responses.
Actual Behavior:
Error responses return a list via response.json().
Failed to transform agent message: req_id: Y7WO3wN4 PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [model_providers:large_language_model:gemini-2.0-flash-001] Error: req_id: 42eW2zZ9 PluginInvokeError: {"args":{},"error_type":"AttributeError","message":"'list' object has no attribute 'get' (model: gemini-2.0-flash-001, provider: vertex_ai)"}"}
API client name and version
google-api-core 2.26.0
Reproduction steps: code
for chunk in response:
pass
(google-api_core-exceptions)
def from_http_response(response):
try:
payload = response.json()
except ValueError:
payload = {"error": {"message": response.text or "unknown error"}}
return format_http_response_error(
response, response.request.method, response.request.url, payload
)
def format_http_response_error(
response, method: str, url: str, payload: Optional[Dict] = None
):
"""Create a :class:
GoogleAPICallErrorfrom a google auth rest response.Reproduction steps: supporting files
file: mydata.csv
Reproduction steps: actual results
file: output.txtmydata.csv
Reproduction steps: expected results
file: output.txtmydata.csv
OS & version + platform
No response
Python environment
No response
Python dependencies
No response
Additional context
No response