fix(chatcmpl): handle reasoning items with provider_data=None#3301
Open
Quratulain-bilal wants to merge 4 commits intoopenai:mainfrom
Open
fix(chatcmpl): handle reasoning items with provider_data=None#3301Quratulain-bilal wants to merge 4 commits intoopenai:mainfrom
Quratulain-bilal wants to merge 4 commits intoopenai:mainfrom
Conversation
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.
seratch
requested changes
May 9, 2026
Member
seratch
left a comment
There was a problem hiding this comment.
Can you resolve the CI error first?
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.
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.
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.