Skip to content

fix: guard against IndexError/ValueError when bare dict has no type args - #3421

Closed
Vitaliy-Pikalo wants to merge 2 commits into
openai:mainfrom
Vitaliy-Pikalo:fix/bare-dict-type-args
Closed

fix: guard against IndexError/ValueError when bare dict has no type args#3421
Vitaliy-Pikalo wants to merge 2 commits into
openai:mainfrom
Vitaliy-Pikalo:fix/bare-dict-type-args

Conversation

@Vitaliy-Pikalo

Copy link
Copy Markdown

Summary

Two crashes when a TypedDict field or model field uses a bare dict (no type params).

1. IndexError in _transform_recursive (_utils/_transform.py) — fixes #3338

get_args(bare_dict) returns (), so [1] index access crashes.
Applied to both sync and async paths.

2. ValueError in construct_type (_models.py) — fixes #3341

_, items_type = get_args(bare_dict) raises ValueError: not enough values to unpack.

Both are simple early-return guards with zero behaviour change for dict[K, V].

Fixes

Closes #3338
Closes #3341

@Vitaliy-Pikalo
Vitaliy-Pikalo requested a review from a team as a code owner June 22, 2026 14:39

Copy link
Copy Markdown
Contributor

Thank you for the contribution. The missing type arguments for bare dict annotations are now handled in model construction and sync/async request transformation by #3760, which is merged into main.

Closing this PR because the merged change resolves the same crash. Please use a release containing #3760 when available; the fix is not included in v3.11.0.

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

Labels

None yet

Projects

None yet

2 participants