Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion google/genai/_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,13 @@ async def __anext__(self) -> Any:

@property
def json(self) -> Any:
if not self.response_stream[0]: # Empty response
# Handle case where response_stream is not a list (e.g., aiohttp.ClientResponse)
# This can happen when the API returns an error and the response object
# is passed directly instead of being wrapped in a list.
# See: https://github.com/googleapis/python-genai/issues/1897
if not isinstance(self.response_stream, list):
return None
if not self.response_stream or not self.response_stream[0]: # Empty response
return ''
return self._load_json_from_response(self.response_stream[0])

Expand Down