-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Decoder Fails to Deserialize Union with Dataclass variants #255
Comments
This is an old issue related to the default Good news, yesterday I finally decided to put an end to this problem and change the logic for deserializing unions containing str, bool, so we can expect a solution soon. In the next release, when deserializing unions, we will check the type of the input value before returning it as is as a string. |
really love this solution, thank you very much, we will definitely test more if you need us, feel free to ping us <3 |
I would appreciate if you check the branch from this PR: |
The fix is ready, will be in the next release. |
Love you, you are a hero |
Description
I'm encountering an issue when using mashumaro to serialize and deserialize a nested dataclass with
Union
properties that include dataclasses and other non-None variants. While the serialization works as expected, the deserialization does not properly decode the union property. Instead of the expected object, the decoded result falls back to a dict type.What I Did
Here is a minimal reproducible example:
Actual Result
The decoded result is:
DC(inner_dc=InnerDC(a={'a': 1}))
The union property a is incorrectly decoded as a dictionary instead of the expected A object.
Expected Result
The decoded result should be:
DC(inner_dc=InnerDC(a=A(a=1)))
It would be helpful to understand whether this is a bug or if additional configuration is required.
The text was updated successfully, but these errors were encountered: