Repository navigation
fix(vertex_ai): honor per-model gcs_bucket_name on managed-file read path - #34847
Conversation
…r-model litellm_params Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR aligns Vertex AI managed-file reads with the per-model GCS configuration already used by writes.
Confidence Score: 5/5The 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.
|
| 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TLDR
Problem this solves:
gcs_bucket_nameHow it solves it:
litellm_paramsGCS_BUCKET_NAME/GCS_PATH_SERVICE_ACCOUNTenvstandard_callback_dynamic_params, mirroring writeRelevant issues
Fixes #32640
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito 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_contentresolution path withGCS_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-modelgcs_bucket_name=my-model-bucketand a batch output id under that bucket, then reads it under three global-env conditions.BEFORE (base
09856a40cd):AFTER (this PR,
5f50791e99):Before the fix the read only worked when the global
GCS_BUCKET_NAMEhappened 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 levelType
🐛 Bug Fix
Changes
VertexAIFilesHandler.afile_contentused to callget_gcs_logging_config(kwargs={})with empty kwargs, which resolves the bucket and service account from the globalGCS_BUCKET_NAME/GCS_PATH_SERVICE_ACCOUNTenv vars only. The resolved env bucket was then used as theconfigured_bucket_namethatvalidate_managed_cloud_file_idcompares 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 viaVertexAIFilesConfig._get_configured_bucket_name, so write and read disagreedThis adds
_resolve_read_gcs_config, which sources the bucket fromlitellm_params["gcs_bucket_name"]/litellm_params["bucket_name"]and the service-account credentials fromlitellm_params["vertex_credentials"](or thevertex_credentialsalready passed toafile_content), each falling back to the corresponding env var. Those values are passed toget_gcs_logging_configthroughstandard_callback_dynamic_params, mirroring the write path and the Bedrock direction in #31435. This also fixes the enterprise batch cost poller, which reaches the sameafile_contentFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/961e64590be3487dac3958f25a6e24eb
Requested by: @shivamrawat1