Skip to content

fix(vertex_ai): honor per-model gcs_bucket_name on managed-file read path - #34847

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_vertex_batch_read_per_model_bucket
Jul 30, 2026
Merged

mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_vertex_batch_read_per_model_bucket

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Vertex managed-file read ignores per-model gcs_bucket_name
  • Batch output in a per-model bucket is unreadable without global env
  • Write honors the per-model bucket, read does not

How it solves it:

  • Read path now resolves bucket + credentials from litellm_params
  • Falls back to GCS_BUCKET_NAME / GCS_PATH_SERVICE_ACCOUNT env
  • Passes them through standard_callback_dynamic_params, mirroring write

Relevant issues

Fixes #32640

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Screenshots / Proof of Fix

A fully-live Vertex batch run needs GCP credentials plus two GCS buckets, which I don't have; the same retrieve flow is also currently blocked by #32580 and #32596, as the reporter noted. So the proof below drives the real VertexAIFilesHandler.afile_content resolution path with GCS_MOCK=true (mocks only the Vertex auth token and the GCS network round-trip, not the bucket/credential resolution logic being fixed). It configures a deployment with a per-model gcs_bucket_name=my-model-bucket and a batch output id under that bucket, then reads it under three global-env conditions.

BEFORE (base 09856a40cd):

CASE 1: GCS_BUCKET_NAME unset (model-group-level config only)
  -> ValueError: GCS_BUCKET_NAME is not set in the environment, but GCS Bucket is being used as a logging callback. Please set 'GCS_BUCKET_NAME' in the environment.
CASE 2: GCS_BUCKET_NAME set to a DIFFERENT env-default bucket
  -> ValueError: file_id bucket does not match the configured storage bucket
CASE 3: GCS_BUCKET_NAME set to MATCH per-model bucket (my-model-bucket)
  -> read OK

AFTER (this PR, 5f50791e99):

CASE 1: GCS_BUCKET_NAME unset (model-group-level config only)
  -> read OK
CASE 2: GCS_BUCKET_NAME set to a DIFFERENT env-default bucket
  -> read OK
CASE 3: GCS_BUCKET_NAME set to MATCH per-model bucket (my-model-bucket)
  -> read OK

Before the fix the read only worked when the global GCS_BUCKET_NAME happened to equal the per-model bucket (Case 3); after the fix the per-model bucket is honored regardless of the env var, so Vertex batch runs entirely at the model-group level

Type

🐛 Bug Fix

Changes

VertexAIFilesHandler.afile_content used to call get_gcs_logging_config(kwargs={}) with empty kwargs, which resolves the bucket and service account from the global GCS_BUCKET_NAME / GCS_PATH_SERVICE_ACCOUNT env vars only. The resolved env bucket was then used as the configured_bucket_name that validate_managed_cloud_file_id compares the file id against, so a batch output written to a per-model bucket was rejected with "file_id bucket does not match the configured storage bucket" (or "GCS_BUCKET_NAME is not set" when the env var was absent). The write path already honored the per-model bucket via VertexAIFilesConfig._get_configured_bucket_name, so write and read disagreed

This adds _resolve_read_gcs_config, which sources the bucket from litellm_params["gcs_bucket_name"] / litellm_params["bucket_name"] and the service-account credentials from litellm_params["vertex_credentials"] (or the vertex_credentials already passed to afile_content), each falling back to the corresponding env var. Those values are passed to get_gcs_logging_config through standard_callback_dynamic_params, mirroring the write path and the Bedrock direction in #31435. This also fixes the enterprise batch cost poller, which reaches the same afile_content

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/961e64590be3487dac3958f25a6e24eb
Requested by: @shivamrawat1

…r-model litellm_params

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@shivamrawat1 shivamrawat1 self-assigned this Jul 27, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR aligns Vertex AI managed-file reads with the per-model GCS configuration already used by writes.

  • Resolves bucket names and service-account credentials from litellm_params, with environment-variable fallbacks.
  • Passes the resolved configuration through the existing GCS callback parameters.
  • Adds regression coverage for per-model buckets, environment fallbacks, and dictionary credentials.

Confidence Score: 5/5

The PR appears safe to merge, with the managed-file read path now consistently honoring deployment-level GCS configuration.

The resolved bucket is used for existing managed-file ID validation and is passed with the resolved credentials through the established GCS download configuration, while the added tests cover the reported precedence and missing-environment cases.

Important Files Changed

Filename Overview
litellm/llms/vertex_ai/files/handler.py Adds consistent per-model GCS bucket and credential resolution to the managed-file read path without introducing an actionable defect.
tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_handler.py Adds focused mock-based regression tests for configuration precedence, environment fallback, credential serialization, and managed-file retrieval.

Reviews (1): Last reviewed commit: "fix(vertex_ai): source managed-file read..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_vertex_batch_read_per_model_bucket (5f50791) with litellm_internal_staging (77ed122)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (09856a4) during the generation of this report, so 77ed122 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@mateo-berri
mateo-berri merged commit 6fe1e73 into litellm_internal_staging Jul 30, 2026
74 checks passed
@mateo-berri
mateo-berri deleted the litellm_fix_vertex_batch_read_per_model_bucket branch July 30, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants