fix: AzureOpenAIChatGenerator.to_dict() crashes when response_format is a plain dict - #12407
Merged
sjrl merged 3 commits intoAug 20, 2026
Conversation
rautaditya2606
requested review from
bogdankostic
and
a lite review from Copilot
and removed request for
a team
August 19, 2026 10:41
|
@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
sjrl
reviewed
Aug 20, 2026
Contributor
|
@bogdankostic I can take this review! |
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.
Related Issues
Closes #12406
Proposed Changes
isinstance(response_format, type)guard before callingissubclass(response_format, BaseModel)inAzureOpenAIChatGenerator.to_dict().test_to_dict_with_dict_response_format) intest/components/generators/chat/test_azure.pycovering both dictionary-based structured output formats:{"type": "json_object"}and{"type": "json_schema", ...}.releasenotes/notes/fix-azure-chat-generator-to-dict-response-format-1b844d5eaadcbd81.yaml.How did you test it?
hatch -e test run pytest test/components/generators/chat/test_azure.py30 passed, 5 skipped in 0.57s.
hatch -e test run pytest test/components/generators/chat/test_azure.py -k test_to_dict_with_dict_response_format2 passed, 34 deselected in 0.19s.
Notes for the reviewer
Root cause:
issubclass()expects a class (type) as its first argument. Whenresponse_formatis provided ingeneration_kwargsas a plain dictionary (standard for OpenAI JSON mode and Structured Outputs), evaluatingissubclass(dict_instance, BaseModel)raises an unhandledTypeError: issubclass() arg 1 must be a classduringto_dict()serialization.This change aligns
AzureOpenAIChatGenerator.to_dict()with the existing pattern inOpenAIChatGenerator.to_dict()(haystack/components/generators/chat/openai.py) andAzureOpenAIResponsesGenerator.to_dict()(haystack/components/generators/chat/azure_responses.py).Reproducer:
Checklist
fix: AzureOpenAIChatGenerator.to_dict() crashes when response_format is a plain dict)releasenotes/notes/fix-azure-chat-generator-to-dict-response-format-1b844d5eaadcbd81.yaml)