llamaIndex - ✅(Solved) Fix [Bug]: google_genai produces cryptic errors for >20MB file uploads with vertexai config [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
run-llama/llama_index#21639Fetched 2026-05-14 03:28:52
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Timeline (top)
cross-referenced ×3labeled ×2commented ×1mentioned ×1

Error Message

This means if you attempt to upload a file >20MB when file_mode isn't inline, the error you get back is 'This method is only supported in the Gemini Developer client.'. Could we error inside of llama-index if vertexai is set and the size is too large with a clearer error (basically use the same branch that errors for inline mode)? We are already checking the size to error if file_mode=inline is set: https://github.com/run-llama/llama_index/blob/0f70eb5ccd723f7a8581977dd4b32056c5b8f1d2/llama-index-integrations/llms/llama-index-llms-google-genai/llama_index/llms/google_genai/utils.py#L288-L294

  • See the confusing error

Fix Action

Fixed

PR fix notes

PR #21642: Google LLMs: Error earlier if file is too large with vertexai client

Description (problem / solution / changelog)

Description

When interacting with Google LLMs and using vertexai, uploading a file >20MB results in a cryptic error. Since we know the google client will fail when we fall through, let's proactively error instead.

Fixes #21639

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes
  • No

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Your pull-request will likely not be merged unless it is covered by some form of impactful unit testing.

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

Changed files

  • llama-index-integrations/llms/llama-index-llms-google-genai/llama_index/llms/google_genai/utils.py (modified, +4/-0)
  • llama-index-integrations/llms/llama-index-llms-google-genai/tests/test_llms_google_genai.py (modified, +14/-0)

PR #21644: fix(google-genai): error early on Vertex AI File API uploads

Description (problem / solution / changelog)

Description

The Vertex AI Gemini API does not support file uploads through the Gemini File API. In create_file_part (llama-index-llms-google-genai), any code path calling client.aio.files.upload() fails on a Vertex client with the cryptic error from google-genai:

This method is only supported in the Gemini Developer client.

The two cases hitting this on Vertex are:

  • file_mode='fileapi' for files of any size
  • file_mode='hybrid' with files larger than 20MB

Both used to surface the confusing message deep inside the upload call. Users get no signal indicating the real cause (Vertex does not expose this API at all) instead of a misconfiguration on their side.

This PR adds a pre-flight check on client.vertexai and raises a clear ValueError with a remediation path before the upload is attempted. Inline mode under 20MB continues to work on Vertex unchanged.

Fixes #21639

New Package?

  • Yes
  • No

Version Bump?

Bumped llama-index-llms-google-genai from 0.9.3 to 0.9.4.

  • Yes
  • No

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added three unit tests under tests/test_llms_google_genai.py:

  • test_create_file_part_raises_on_vertexai_with_fileapi — fileapi mode + Vertex client → ValueError, no upload attempted.
  • test_create_file_part_raises_on_vertexai_with_large_hybrid_file — 21MB hybrid + Vertex → ValueError, no upload attempted.
  • test_create_file_part_inline_still_works_on_vertexai — inline mode + Vertex + small file → returns Part, no upload attempted (regression guard).

Also updated the two pre-existing create_file_part tests to set mock_client.vertexai = False, since a bare MagicMock auto-generates a truthy vertexai attribute.

Local results:

  • uv run -- pytest tests/ → 33 passed, 46 skipped (skips need GOOGLE_API_KEY / GOOGLE_GENAI_USE_VERTEXAI env vars).

  • uv run -- ruff check on the changed files → clean.

  • uv run -- ruff format --check on the changed files → clean.

  • codespell on the changed files → clean.

  • I added new unit tests to cover this change

  • I believe this change is already covered by existing unit tests

Suggested Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (CHANGELOG entry)
  • I have added Google Colab support for the newly added notebooks (N/A, no notebooks)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes
  • I ran ruff check and ruff format on the modified files

AI assistance disclosure (per CONTRIBUTING.md)

Drafted with Claude Code assistance. The fix is a 10-line guard plus three unit tests. I reviewed every line, traced the google-genai failure mode against the SDK source linked in the issue, and ran the full local test suite and the linters.

Changed files

  • llama-index-integrations/llms/llama-index-llms-google-genai/CHANGELOG.md (modified, +6/-0)
  • llama-index-integrations/llms/llama-index-llms-google-genai/llama_index/llms/google_genai/utils.py (modified, +10/-0)
  • llama-index-integrations/llms/llama-index-llms-google-genai/pyproject.toml (modified, +1/-1)
  • llama-index-integrations/llms/llama-index-llms-google-genai/tests/test_llms_google_genai.py (modified, +75/-0)

PR #21646: fix: reject Vertex AI file uploads in google genai

Description (problem / solution / changelog)

## Summary

  • raise a clear ValueError before Google GenAI File API uploads are attempted with a Vertex AI client
  • keep small hybrid files on the inline path
  • add regression coverage for fileapi mode and large hybrid files with Vertex AI

Fixes #21639.

To verify

  • python -m py_compile llama_index\llms\google_genai\utils.py tests\test_llms_google_genai.py
  • python -m ruff check llama_index\llms\google_genai\utils.py tests\test_llms_google_genai.py
  • python -m ruff format --check llama_index\llms\google_genai\utils.py tests\test_llms_google_genai.py
  • python -m pytest tests\test_llms_google_genai.py -q

Changed files

  • llama-index-integrations/llms/llama-index-llms-google-genai/llama_index/llms/google_genai/utils.py (modified, +12/-5)
  • llama-index-integrations/llms/llama-index-llms-google-genai/tests/test_llms_google_genai.py (modified, +30/-0)
RAW_BUFFERClick to expand / collapse

Bug Description

Uploading files using a vertexai client is not supported on the google side: https://github.com/googleapis/python-genai/blob/main/google/genai/files.py#L593-L596

This means if you attempt to upload a file >20MB when file_mode isn't inline, the error you get back is 'This method is only supported in the Gemini Developer client.'. Could we error inside of llama-index if vertexai is set and the size is too large with a clearer error (basically use the same branch that errors for inline mode)?

We are already checking the size to error if file_mode=inline is set: https://github.com/run-llama/llama_index/blob/0f70eb5ccd723f7a8581977dd4b32056c5b8f1d2/llama-index-integrations/llms/llama-index-llms-google-genai/llama_index/llms/google_genai/utils.py#L288-L294

Version

0.8.7

Steps to Reproduce

  • Configure vertex AI client
  • Upload a file >20MB
  • See the confusing error

Relevant Logs/Tracebacks

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

llamaIndex - ✅(Solved) Fix [Bug]: google_genai produces cryptic errors for >20MB file uploads with vertexai config [3 pull requests, 1 comments, 2 participants]