[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC
Maintainers usually reply within 1 day
@Venkaiahbabuneelam is already working on this.
Since Oct 5, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start in google/genai/_extra_utils.py at convert_if_exist_pydantic_model and reproduce the typing.List and typing.Dict examples from the issue. Check the behavior when get_args(annotation) is empty, then verify that both calls return their original values without raising errors.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 4.1k
- Forks
- 1.1k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 90
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/python-genai
-
Interactions retries ignore the documented `initial_delay` and `max_delay` defaultsPossibly taken @Venkaiahbabuneelam claimed this 4 days ago. Openpriority: p2 status:awaiting user response type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
googleapis/python-genai#3317 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Test import module that doesn't existPossibly taken @Venkaiahbabuneelam claimed this 30 days ago. Openpriority: p2 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
googleapis/python-genai#3122 · 6 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Curated history keeps half a user turn when the model turn is invalidPossibly taken @Venkaiahbabuneelam claimed this 39 days ago. Openpriority: p2 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
googleapis/python-genai#3051 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Structured-output continuation merge raises AttributeError: __pydantic_generic_metadata__ when a hop has parsed JSONPossibly taken @Venkaiahbabuneelam claimed this 3 days ago. Openpriority: p2 type: bug
googleapis/python-genai#3350 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Automatic function calling rejects `datetime` and `UUID` argumentsPossibly taken @Venkaiahbabuneelam claimed this 3 days ago. Openpriority: p2 type: bug
Difficulty 3/5 1-2 days Newbie friendliness 75/100
googleapis/python-genai#3331 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in googleapis/python-genai
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dbt-labs/spark-utils#51 ·
-
bug pydanty:is-working
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pydantic/pydantic-ai#13444 ·
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
changelog investigate
Difficulty 1/5 Under an hour Newbie friendliness 68/100
ramnes/notion-sdk-py#502 ·