[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
Línea de trabajo
Comienza en google/genai/_extra_utils.py, en convert_if_exist_pydantic_model, y reproduce los ejemplos de typing.List y typing.Dict del issue. Comprueba el comportamiento cuando get_args(annotation) está vacío y verifica después que ambas llamadas devuelvan sus valores originales sin generar errores.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 4k
- Forks
- 1k
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 54
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de googleapis/python-genai
-
Curated history keeps half a user turn when the model turn is invalidPosiblemente ocupada @Venkaiahbabuneelam la tomó hace 2 días. Abiertopriority: p2 status:awaiting user response type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
googleapis/python-genai#3051 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Name collision in google.genai.interactions: triggers.Interaction shadows response model Interaction in static type checkersPosiblemente ocupada @Venkaiahbabuneelam la tomó hace 9 días. Abiertopriority: p2 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
googleapis/python-genai#3013 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Callable tools: optional scalar parameters (`int | None`) get `"type": "object"` in `parameters_json_schema`, so Gemini sends `{}`Posiblemente ocupada @Venkaiahbabuneelam la tomó hoy. Abiertopriority: p2 type: bug
googleapis/python-genai#3060 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Gemini API latency has recently increased significantly, especially with store=truePosiblemente ocupada @Venkaiahbabuneelam la tomó hoy. Abiertopriority: p3 status:awaiting user response type: question
googleapis/python-genai#3059 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
live.connect() (Vertex AI) resolves ADC and refreshes the OAuth token synchronously on the event loop on every connectPosiblemente ocupada @Venkaiahbabuneelam la tomó hace 1 día. Abiertopriority: p2 type: bug
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
googleapis/python-genai#3056 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de googleapis/python-genai
Issues similares
-
defect from-review v0.9.2
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
khuisman/mcp-gee-sweet#926 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 84/100
EtanHey/brainlayer#1164 ·
Los mantenedores suelen responder en 1 día
-
bug security
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
yunaremaia/vibeguard#141 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
PrismorSec/prismor#599 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
iii-hq/iii#2278 · 1 comentario ·
Los mantenedores suelen responder en 1 día