googleapis / googleapis/python-genai

client.files.list() raises ServerError 500: "Failed to convert server response to JSON"

Open
#815 19 comments 8 reactions 1 assignee Assigned to @kkorpal View on GitHub
api: gemini-api priority: p2 type: bug
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

Hi team,

I'm using the Google Generative AI Python SDK and encountering an unexpected internal error when calling client.files.list(). This function was working until yesterday, but it has now started consistently throwing a server-side error. Below is the traceback:
Traceback (most recent call last):
File "/home/hetpandya/Research/Loom AI/list.py", line 10, in
for f in client.files.list():
^^^^^^^^^^^^^^^^^^^
File "/home/hetpandya/.local/lib/python3.12/site-packages/google/genai/files.py", line 714, in list
self._list(config=config),
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hetpandya/.local/lib/python3.12/site-packages/google/genai/files.py", line 385, in _list
response_dict = self._api_client.request(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hetpandya/.local/lib/python3.12/site-packages/google/genai/_api_client.py", line 674, in request
response = self._request(http_request, stream=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hetpandya/.local/lib/python3.12/site-packages/google/genai/_api_client.py", line 603, in _request
errors.APIError.raise_for_response(response)
File "/home/hetpandya/.local/lib/python3.12/site-packages/google/genai/errors.py", line 103, in raise_for_response
raise ServerError(status_code, response_json, response)
google.genai.errors.ServerError: 500 INTERNAL. {'error': {'code': 500, 'message': 'Failed to convert server response to JSON', 'status': 'INTERNAL'}}

Environment:

SDK version: [google-genai==1.11.0]

Python version: 3.9

OS: Ubuntu 22.04

Steps to reproduce:

Set up client from the SDK.

Call client.files.list()

Observe the crash.

Expected behavior:

The method should return a list of files or an appropriate client-side error, not a server-side 500 with an invalid JSON response.
Actual behavior:

The SDK raises google.genai.errors.ServerError with a message indicating the response couldn't be converted to JSON.

Please let me know if there's an alternative method I should use, or if this is a known issue being addressed.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.