Skip to content

fix: cherry-pick upstream metadata None check [sc-521238] - #28

Merged
mateo-di merged 4 commits into
carto/mainfrom
bug/sc-521238/google-custom-model-not-working-on-existing-4
Nov 14, 2025
Merged

fix: cherry-pick upstream metadata None check [sc-521238]#28
mateo-di merged 4 commits into
carto/mainfrom
bug/sc-521238/google-custom-model-not-working-on-existing-4

Conversation

@mateo-di

Copy link
Copy Markdown
Collaborator

Description

Shortcut

Cherry-picks upstream fix for TypeError when litellm_params['metadata'] is None for custom Google AI Studio models.

Bug Report

Reported by: Ana Manzanares (Slack, 2025-11-12)
Error: TypeError: argument of type 'NoneType' is not iterable at transformation.py:369
Affected: Custom Google AI Studio models (e.g., ac_cb7b9151::gemini-2.5-pro)
Works: OpenAI models, CARTO Managed Models

Solution

Cherry-picked two upstream commits:

  1. Bug introduced (March 2025): Optional labels field in Vertex AI request

  2. Bug fixed (September 2025): Check if metadata is not None

Changes

Fixed: litellm/llms/vertex_ai/gemini/transformation.py:369

  • Added metadata is not None and before the in check
  • Bonus: Changed type(v) is str to isinstance(v, str) (better practice)

Note: Cherry-pick initially removed speechConfig from vertex_ai.py due to merge context differences - this was corrected and speechConfig is preserved.

Type of change

  • Fix (cherry-pick from upstream)

Acceptance

GitHub Actions will validate:

  1. All existing Gemini/Vertex AI tests pass
  2. No regressions introduced

Basic checklist

  • Good PR name
  • Shortcut link
  • Just one issue per PR

Notes

  • Clean cherry-pick of upstream's fix
  • Upstream resolved this in September 2025
  • Low risk: Defensive programming fix
  • No custom CARTO code needed

vvidovic and others added 2 commits November 12, 2025 09:42
If the client sets the `labels` field in the request to the LiteLLM:
- pass the `labels` field to the Vertex AI backend

If the client sets the `metadata` field in the request to the LiteLLM:
- if the `labels` field is not set, fill it with `metadata` key/value
  pairs for all string values
@mateo-di
mateo-di marked this pull request as ready for review November 12, 2025 12:58
The check_if_part_exists_in_parts function exists in upstream-sync-resolver/24
but not in carto/main yet. Removing tests until that branch is merged.
The upstream cherry-pick removed CARTO's provider-specific labels logic from PR BerriAI#14563.
Google AI Studio (gemini provider) should NOT include labels field.

This commit preserves BOTH fixes:
- Upstream metadata None check (from commit 944176f)
- CARTO provider-aware filtering (from PR BerriAI#14563 / commit 5748d6d)
@mateo-di
mateo-di merged commit 41441b9 into carto/main Nov 14, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants