- 
                Notifications
    
You must be signed in to change notification settings  - Fork 476
 
Description
Description of the bug:
When calling the standard genai.upload_file() function to upload a media file (e.g., an MP4 video), the underlying API client library throws a TypeError. This occurs on macOS with Python 3.9 installed via pyenv.
Environment:
OS: macOS
Python: 3.9 (via pyenv)
Library Versions:
google-generativeai: 0.8.5
google-ai-generativelanguage: 0.6.15
google-api-python-client: 2.184.0
google-api-core: 2.26.0
google-auth: 2.41.1
Minimal Reproducible Code: (You can attach the bug_report_repro.py file I created for you)
Actual vs expected behavior:
Actual Behavior: The call to genai.upload_file() fails with a TypeError, asking for a ragStoreName parameter, which is unrelated to the File API. The following traceback is produced:
Traceback (most recent call last):
File "/path/to/your/script.py", line 31, in 
media_file = genai.upload_file(path=file_path, mime_type=mime_type)
File "/path/to/your/myenv/lib/python3.9/site-packages/google/generativeai/files.py", line 85, in upload_file
response = client.create_file(
File "/path/to/your/myenv/lib/python3.9/site-packages/google/generativeai/client.py", line 120, in create_file
request = self._local.discovery_api.media().upload(body={"file": file}, media_body=media)
File "/path/to/your/myenv/lib/python3.9/site-packages/googleapiclient/discovery.py", line 1114, in method
raise TypeError('Missing required parameter "%s"' % name)
TypeError: Missing required parameter "ragStoreName"
Expected Behavior: The genai.upload_file() function should successfully upload the file and return a google.generativeai.types.File object without errors, and without requiring parameters from the Corpus/RAG API.
Any other information you'd like to share?
The following debugging steps have been attempted but did not resolve the issue:
Upgraded Packages: Ran pip install --upgrade google-generativeai, but version 0.8.5 was already the latest available.
Cleared API Cache: Deleted the ~/.cache/google-api-python-client directory to force the API client to rebuild its discovery cache.
Explicitly Set MIME Type: Modified the call to genai.upload_file(path=..., mime_type=...) to rule out issues with automatic MIME type detection.
Checked Media File Integrity: Ensured the media file being uploaded was not empty or corrupted. The error occurs even with a valid, newly created file.