Repository navigation
Conversation
get_args(dict) returns () but _transform_recursive and _async_transform_recursive unconditionally indexed [1], causing IndexError on bare dict annotations. Added bounds check: if get_args(stripped_type) is empty, return data unchanged.
LeonxLJX
requested review from
andrewtlw,
cwilmott-groq and
pmichalina-groq
as code owners
November 29, 2026 18:00
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken
Calling transform() or async_transform() with a mapping value typed as a bare dict (no type parameters, e.g. Annotated[dict, PropertyInfo(alias='key')]) raises IndexError. The same crash occurs in the async counterpart _async_transform_recursive.
Reproduction
``python
from typing_extensions import Annotated
from groq._utils._transform import transform, PropertyInfo
transform({"key": {"a": 1}}, Annotated[dict, PropertyInfo(alias="key")])
IndexError: tuple index out of range
``
Root cause
get_args(dict) returns an empty tuple (). Both _transform_recursive (line 183) and _async_transform_recursive (line 349) unconditionally index [1] without checking whether type args exist.
Fix
Added a bounds check in both functions: if get_args(stripped_type) is empty, return data unchanged. When type args are present the existing dict[K, V] path continues to work as before.
Testing
Verified fix works correctly with the reproduction case above. Also ran regression test with Annotated[Dict[str, str], ...] to ensure parameterized dicts still transform properly.
This PR references and supersedes closed PR #275 by devteamaegis.