You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used another json library (orjson) to convert to and from JSON, thinking I could get away with only using marshmallow for deserialization.
orjson serializes Enums by value, but marshmallow serializes Enums by key, resulting in an error:
File "/home/awagner/miniconda3/envs/luigi_py36/lib/python3.6/site-packages/marshmallow/schema.py", line 904, in _do_load
raise exc
marshmallow.exceptions.ValidationError: {'model_size': ['Invalid enum member MyEnumValue']}
The solution was to use marshmallow for both serialization and deserialization.
If this is a common enough mistake, perhaps the error message could be improved, especially since you can detect if the value found matches one of the expected enum values. (in my case the Enum was string valued)
Otherwise, this ticket at least gives something for people to hit while searching.
Thanks for the useful library!
The text was updated successfully, but these errors were encountered:
I made the following usage mistake:
I used another json library (orjson) to convert to and from JSON, thinking I could get away with only using marshmallow for deserialization.
orjson serializes Enums by value, but marshmallow serializes Enums by key, resulting in an error:
The solution was to use marshmallow for both serialization and deserialization.
If this is a common enough mistake, perhaps the error message could be improved, especially since you can detect if the value found matches one of the expected enum values. (in my case the Enum was string valued)
Otherwise, this ticket at least gives something for people to hit while searching.
Thanks for the useful library!
The text was updated successfully, but these errors were encountered: