FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(afc): guard type argument unpacking for unsubscripted typing.List and typing.Dict in convert_if_exist_pydantic_model by chauvuusvn · Pull Request #3045 · googleapis/python-genai · GitHub

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

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

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

1 participant


Back | FazBrowse Home | New Git URL