marshmallow-code / marshmallow-code/marshmallow

fields.Function's _serialize method passes in obj instead of value

Open
#1,683 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

As a result, everytime you serialize a field that is a Function, it tries to serialize the containing object instead of the value.

offending code:
https://github.com/marshmallow-code/marshmallow/blob/dev/src/marshmallow/fields.py#L1803

should be:

```python
return self._call_or_raise(self.serialize_func, value, attr)
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/marshmallow/fields.py#L1803 and compare Function._serialize with the serialize_func call shown in the issue. Exercise serialization of a Function field and verify that the callback receives the field value rather than the containing object.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.