镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(afc): guard type argument unpacking for unsubscripted typing.List and typing.Dict in convert_if_exist_pydantic_model - #3045

Open
chauvuusvn wants to merge 1 commit into
googleapis:mainfrom
chauvuusvn:fix/afc-unsubscripted-typing-generics
Open

chauvuusvn wants to merge 1 commit into
googleapis:mainfrom
chauvuusvn:fix/afc-unsubscripted-typing-generics

Conversation

@chauvuusvn

Copy link
Copy Markdown

Summary

Fixes #3044

In convert_if_exist_pydantic_model, unsubscripted generic type annotations like typing.List or typing.Dict caused IndexError or ValueError when attempting to unpack empty get_args(annotation) tuples during Automatic Function Calling (AFC).

Changes

  1. Guarded get_args(annotation) for list origins before indexing [0].
  2. Guarded get_args(annotation) for dict origins to require len(args) == 2 before unpacking key/value types.
  3. Added test assertions in google/genai/tests/afc/test_convert_if_exist_pydantic_model.py verifying that typing.List and typing.Dict convert cleanly without exceptions.

Author: Chau Vu / CPF-FAMILY (@chauvuusvn)

… and typing.Dict in convert_if_exist_pydantic_model
@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Oct 5, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:M Code changes between 10-40 lines label Oct 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Code changes between 10-40 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC

2 participants