[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFC
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Bắt đầu trong google/genai/_extra_utils.py tại convert_if_exist_pydantic_model và tái hiện các ví dụ typing.List và typing.Dict từ issue. Kiểm tra hành vi khi get_args(annotation) rỗng, sau đó xác minh rằng cả hai lệnh gọi đều trả về các giá trị ban đầu mà không phát sinh lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 4k
- Fork
- 1k
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 52
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/python-genai
-
priority: p2 status:awaiting user response type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
googleapis/python-genai#3051 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Name collision in google.genai.interactions: triggers.Interaction shadows response model Interaction in static type checkersCó thể đã có người làm @Venkaiahbabuneelam đã nhận 7 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
googleapis/python-genai#3013 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
googleapis/python-genai#3056 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Vertex batch embeddings (gemini-embedding-001): no way to attach billing labels; job and row labels never reach Cloud BillingCó thể đã có người làm @Venkaiahbabuneelam đã nhận hôm nay. Đang mởpriority: p3 type: question
googleapis/python-genai#3053 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority: p2 type: bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
googleapis/python-genai#3031 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/python-genai
Issue tương tự
-
bug llm translation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Arkansas 2025 tax is $1.70 high above $100,000 net taxable income ($3,809 + 3.9% rule)Có thể đã có người làm @PavelMakarchuk đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
PolicyEngine/policyengine-us#9828 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jellyfin/jellyfin-mpv-shim#800 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
skillfs: one malformed chat-log line aborts the entire skill-usage analysis (skill_usage_from_chat_logs.py)Có thể đã có người làm @zjncs đã nhận hôm nay. Đang mởcomponent:skillfs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
agentic-os-org/ANOLISA#6116 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
P4: low query
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jeffknupp/association#336 ·