Repository navigation
🐛 Fix exclude_unset/exclude_defaults/exclude_none not propagated to ServerSentEvent data - #16145
Closed
SAURABHSALVE wants to merge 2 commits into
Closed
SAURABHSALVE wants to merge 2 commits into
SAURABHSALVE wants to merge 2 commits into
Conversation
Member
|
Thanks for your interest and efforts, but let's keep it closed until maintainers can review the discussion #15703 and decide how to handle it. We are trying to keep things clean and ask to only open PRs when it's explicitly requested by maintainers.
Thanks for understanding! |
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.
Problem
ServerSentEvent(data=...)serializes Pydantic models viamodel_dump_json()without passing
exclude_unset,exclude_defaults, orexclude_none. Everyother serialization path in FastAPI threads these parameters through:
ModelField.serialize_json()— used for plain (non-wrapped) stream itemsserialize_response()— used for regular (non-streaming) responsesThis makes
ServerSentEventdata the only path that ignores these route-levelsettings, so the same model serializes differently depending on how it is
yielded: