[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
Direzione di ricerca
Inizia in google/genai/_extra_utils.py, in corrispondenza di convert_if_exist_pydantic_model, e riproduci gli esempi di typing.List e typing.Dict dell’issue. Controlla il comportamento quando get_args(annotation) è vuoto, quindi verifica che entrambe le chiamate restituiscano i valori originali senza generare errori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
In google/genai/_extra_utils.py, inside convert_if_exist_pydantic_model:
if isinstance(value, list) and get_origin(annotation) == list:
item_type = get_args(annotation)[0] # Crashes with IndexError on typing.List
...
if isinstance(value, dict) and get_origin(annotation) == dict:
_, value_type = get_args(annotation) # Crashes with ValueError on typing.Dict
...
When a user defines a tool function with unsubscripted generic type annotations like typing.List or typing.Dict:
get_origin(List)islist, butget_args(List)returns(). Accessing[0]raisesIndexError: tuple index out of range.get_origin(Dict)isdict, butget_args(Dict)returns(). Unpacking_, value_type = get_args(Dict)raisesValueError: not enough values to unpack (expected 2, got 0).
This causes Automatic Function Calling (AFC) to crash during function argument conversion.
Steps to Reproduce
from typing import Dict, List
from google.genai._extra_utils import convert_if_exist_pydantic_model
# 1. Test typing.List
convert_if_exist_pydantic_model([1, 2], List, 'items', 'my_func')
# Raises IndexError: tuple index out of range!
# 2. Test typing.Dict
convert_if_exist_pydantic_model({'a': 1}, Dict, 'config', 'my_func')
# Raises ValueError: not enough values to unpack (expected 2, got 0)!
Expected Behavior
If get_args(annotation) is empty for unsubscripted typing.List or typing.Dict, convert_if_exist_pydantic_model should safely return the original value without raising IndexError or ValueError.
- Lingua principale
- Python
- Stelle
- 4k
- Fork
- 1k
- Merge medio
- 1g 18h
- PR unite (30g)
- 52
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/python-genai
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
googleapis/python-genai#3051 ·
I maintainer di solito rispondono entro 1 giorno
-
Name collision in google.genai.interactions: triggers.Interaction shadows response model Interaction in static type checkersForse già presa @Venkaiahbabuneelam l’ha presa 7 giorni fa. Apertapriority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
googleapis/python-genai#3013 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
googleapis/python-genai#3031 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Live `AsyncSession.send_tool_response` fails with `TypeError` when `FunctionResponse.parts` carries inline bytesForse già presa @Venkaiahbabuneelam l’ha presa 5 giorni fa. Apertapriority: p2 type: bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
googleapis/python-genai#3022 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Live API] gemini-3.8-live-extended-thinking: announces tool call then says "I apologize, but a system error occurred." with no functionCall frame - 61% of tool runs (n=64)Forse già presa @Venkaiahbabuneelam l’ha presa 6 giorni fa. Apertapriority: p2 status:awaiting user response type: bug
googleapis/python-genai#3015 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleapis/python-genai
Issue simili
-
jobs restart --verify: hotlane restart timeout (10s) shorter than its shutdown (~30s) → false exit 1Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
EtanHey/brainlayer#1072 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
_apply_doc_content: a cancel during the shielded image gather still sends the content batchUpdateApertaenhancement
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 80/100
khuisman/mcp-gee-sweet#904 ·
I maintainer di solito rispondono entro 1 giorno
-
Lychee link check failedAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
-
CORE-HIST-005/006 multi-turn history tests send three different messages with the same messageIdAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
a2aproject/a2a-tck#248 ·