Skip to content

fix(chatcmpl): handle reasoning items with provider_data=None#3301

Open
Quratulain-bilal wants to merge 4 commits intoopenai:mainfrom
Quratulain-bilal:fix/chatcmpl-reasoning-provider-data-none
Open

fix(chatcmpl): handle reasoning items with provider_data=None#3301
Quratulain-bilal wants to merge 4 commits intoopenai:mainfrom
Quratulain-bilal:fix/chatcmpl-reasoning-provider-data-none

Conversation

@Quratulain-bilal
Copy link
Copy Markdown
Contributor

Converter.items_to_messages assumed reasoning_item["provider_data"] was always either absent or a dict, calling .get("model", "") directly on the result of reasoning_item.get("provider_data", {}). When the field is explicitly set to None which is preserved through JSON round-trips and common from external producers/storage this raised AttributeError: 'NoneType' object has no attribute 'get' before any reasoning content could be processed, breaking conversion entirely.

Treat any non-dict provider_data (None, list, scalar) as missing, which matches the existing "ignore the check when provider_data is empty" fallback already used a few lines below.

Quratulain-bilal and others added 2 commits May 9, 2026 15:19
Converter.items_to_messages assumed reasoning_item["provider_data"] was
always either absent or a dict, calling .get("model", "") directly on the
result of reasoning_item.get("provider_data", {}). When the field is
explicitly set to None — which is preserved through JSON round-trips and
common from external producers/storage — this raised
AttributeError: 'NoneType' object has no attribute 'get' before any
reasoning content could be processed, breaking conversion entirely.

Treat any non-dict provider_data (None, list, scalar) as missing, which
matches the existing "ignore the check when provider_data is empty"
fallback already used a few lines below.
@github-actions github-actions Bot added bug Something isn't working feature:chat-completions labels May 9, 2026
@seratch seratch marked this pull request as draft May 9, 2026 10:56
@Quratulain-bilal Quratulain-bilal marked this pull request as ready for review May 9, 2026 11:54
Copy link
Copy Markdown
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you resolve the CI error first?

@seratch seratch marked this pull request as draft May 9, 2026 12:02
Quratulain-bilal and others added 2 commits May 9, 2026 18:25
The previous test built a TResponseInputItem and then assigned to
item['provider_data'], which mypy rejected because every TypedDict in the
TResponseInputItem union without a 'provider_data' key produced a
typeddict-unknown-key error (58 in total).

Build the input as a plain dict[str, Any] and cast at the call site so
mypy only sees the cast, not the assignment. No runtime behavior change.
@Quratulain-bilal Quratulain-bilal marked this pull request as ready for review May 9, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:chat-completions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants