You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC #3044
In google/genai/_extra_utils.py, inside convert_if_exist_pydantic_model:
ifisinstance(value, list) andget_origin(annotation) ==list:
item_type=get_args(annotation)[0] # Crashes with IndexError on typing.List
...
ifisinstance(value, dict) andget_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) is list, but get_args(List) returns (). Accessing [0] raises IndexError: tuple index out of range.
get_origin(Dict) is dict, but get_args(Dict) returns (). Unpacking _, value_type = get_args(Dict) raises ValueError: not enough values to unpack (expected 2, got 0).
This causes Automatic Function Calling (AFC) to crash during function argument conversion.
Steps to Reproduce
fromtypingimportDict, Listfromgoogle.genai._extra_utilsimportconvert_if_exist_pydantic_model# 1. Test typing.Listconvert_if_exist_pydantic_model([1, 2], List, 'items', 'my_func')
# Raises IndexError: tuple index out of range!# 2. Test typing.Dictconvert_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.
Hi @chauvuusvn, Thank you for bringing this to our attention. We truly appreciate you flagging this issue regarding unsubscripted typing.List and typing.Dict crashing convert_if_exist_pydantic_model in AFC, we will file a bug internally.
Thanks
Activity
Venkaiahbabuneelam commentedon Oct 5, 2026
Hi @chauvuusvn, Thank you for bringing this to our attention. We truly appreciate you flagging this issue regarding unsubscripted typing.List and typing.Dict crashing convert_if_exist_pydantic_model in AFC, we will file a bug internally.
Thanks
Fix unsubscripted typing.List/Dict crash in convert_if_exist_pydantic…
fix: Return values unchanged for unsubscripted typing.List and typing…