[BUG] Mashumaro JSONEncoder
/JSONDecoder
behavior differs with to_json
/from_json
.
#5588
Closed
2 tasks done
Labels
bug
Something isn't working
Describe the bug
Hi Team! We recently pulled
master
into our fork (where we're trying to find+fix bugs related to our use case), and found that a recent change (flyteorg/flytekit#2554) broke expected behavior. I'm very much a fan of not requiring the use of these mixins, but surprisingly the behavior ofJSONEncoder(...).encode()
ends up different fromto_json
. This may be considered a mashumaro bug (and I've opened Fatal1ty/mashumaro#239 there as well), but it breaks existing flytekit behavior.This relates to the ability of mashumaro to encode/decode classes that use the
Discriminator
pattern in order to serialize/deserialize subclasses of a generic class.to_json
correctly encodes to the target subclass, whileJSONEncoder(BaseClass).encode()
only encodes to the base class.Expected behavior
Subclass encoding/decoding should still be able to expand to subclasses correctly. As such, if
to_json
andfrom_json
exist they should be preferred over theJSONEncoder
andJSONDecoder
approaches.Additional context to reproduce
Outputs:
Screenshots
No response
Are you sure this issue hasn't been raised already?
Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: