`serialize`'s `on_error` missing cases
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 778
- Avg merge
- 2h 50m
- Merged PRs (30d)
- 3
Description
AFAICT `serialize` only handles `on_error` `"message"` and `"raise"`. Though `"ignore"` is not handled. If `on_error` is anything unexpected, there is no checking or error handling for that.
https://github.com/dask/distributed/blob/223c8154d7abee9837399933b8b2db5f78d9a278/distributed/protocol/serialize.py#L352-L362
If `on_error` is `"ignore"`, nothing is returned (meaning `None` is returned). Same happens with `on_error="foo"`. This can be problematic:
```python
from distributed.protocol import deserialize, dumps, loads, serialize, to_serialize
class Foo:
def __reduce__(self, protocol):
raise ValueError("foo")
obj = Foo()
msg = {"data": to_serialize(obj)}
# raises `TypeError` as `None` can't be unpacked
header, frames = serialize(msg, on_error="ignore")
# same `TypeError` (though less obvious what is happening)
dumps(msg, on_error="ignore")
```
Contributor guide
Assessment
This issue has not been assessed yet.