-
Notifications
You must be signed in to change notification settings - Fork 451
fix(models): correctly unwrap Annotated types for RawMessageStreamEvent deserialization #1167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(models): correctly unwrap Annotated types for RawMessageStreamEvent deserialization #1167
Conversation
…ctly Fixes intermittent deserialization failures where Annotated types were not unwrapped if wrapped in a TypeAlias or ifmetadata was provided. This ensures discriminated unions like RawMessageStreamEvent are correctly processed.
|
I've verified the fix locally with reproduction scripts specifically targeting the TypeAliasType + Annotated nesting scenario. This should resolve the reported intermittent issues with RawMessageStreamEvent deserialization. |
|
Thank you for your contribution! Would it be possible to add a test for this? |
…discriminated unions and fix Pydantic v1 model_dump regression
|
@felixfbecker I've added comprehensive regression tests to |
…l Annotated metadata
|
@felixfbecker I've refined the fix to address the failure observed in CI. The issue was that passing a I've updated
This improved approach is more robust and passes correctly in environments where |
…s to module level
CI Passing ✅All CI checks are now passing after the latest commits. Here's a summary of the changes made: Changes Summary
Test CoverageAll 51 tests pass, including the three new regression tests:
Ready for review! |
This PR fixes a bug where construct_type failed to correctly unwrap Annotated types when they were wrapped in TypeAlias (common in newer Python versions/setups) or when metadata was explicitly provided. This ensures that discriminated unions like RawMessageStreamEvent are correctly processed, preventing intermittent Unexpected event runtime type errors during streaming (fixes #941).