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
After fixing #1993 in #1994, I stumbled upon another bug. List items are serialized more than once by fields.Method. To reproduce the bug, let's have the following Schema:
The cause of the problem is, the serialize_me method never receives the value that should be serialized (neither as an argument, nor in **kwargs), it only gets the obj that is being serialized. By looking at the source code here, we see that the _serialize_method of fields.Method does not get the value as parameter.
Although the fix seems to be quite simple, just pass the value to the _serialize_method, it would be a breaking API change that would need a new major release.
To avoid a new major release, I would like to ask the maintainer(s) of the repository if they see any other solution to fix this bug?
The text was updated successfully, but these errors were encountered:
benedekh
changed the title
Bug: Fields items are serialized more than once by fields.Method.
Bug: Fields items are serialized more than once by fields.Method
Jun 10, 2022
When serializing a list, obj is the object, attr the name of the attribute holding the list and value the content of that attribute (the elements in the list). Then we call the inner field serialize method on each element, and we pass attr and obj which doesn't make much sense considering that at this stage it is supposed to work on a single element, with no knowledge about the list. We can't really make up an attr and an obj that make sense here.
I don't see a nice solution to this. In fact, what I say in #2039 is that we shouldn't pass attr and an obj but this would break Function and Method field and I have no idea how to make those fields work without passing the object.
Thanks for adding another example of why this design is wrong, but I can't think of a better implementation.
(Sorry I didn't get the time to further look into #1993 and #1994.)
After fixing #1993 in #1994, I stumbled upon another bug. List items are serialized more than once by
fields.Method
. To reproduce the bug, let's have the following Schema:Let's have the following serialization code:
After serialization
dumped
will beinstead of
The cause of the problem is, the
serialize_me
method never receives the value that should be serialized (neither as an argument, nor in**kwargs
), it only gets theobj
that is being serialized. By looking at the source code here, we see that the_serialize_method
offields.Method
does not get thevalue
as parameter.Although the fix seems to be quite simple, just pass the
value
to the_serialize_method
, it would be a breaking API change that would need a new major release.To avoid a new major release, I would like to ask the maintainer(s) of the repository if they see any other solution to fix this bug?
The text was updated successfully, but these errors were encountered: